-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add protocol default value for version and model endpoints & relax supported enum in OpenAPI #529
Conversation
update | ||
model_endpoints | ||
set protocol = 'HTTP_JSON' | ||
where protocol is null or protocol = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super tiny nit but can we have the SQL commands in capital letters for consistency with other migration scripts (and for very slightly better readability) 😅 Thanks! 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually are we planning to enforce the setting of the protocol
field (aka we are no longer accepting non-null values)? If we are already performing this DB migration, and neither the SDK/UI/API accept null values for the protocol
field for new models created, then changing the swagger client specs to accept null values will allow users to use null values for the protocol
field via the SDK, which isn't what we want right?
I think my point is that performing the DB migration (there's no need to add it to the repo) is enough for all existing models saved without a protocol
specified, and we shouldn't modify the swagger specs, since all the newer models already contain a value for that field.
That's for |
Ahhh I see I forgot there's another table to update. Hmmm in that case all's good if we manage to migrate the |
🙏 .Yup if the |
Okay, after spending time poking into this whole thing, I have a couple of observations and changes to propose: SDKAs the SDK used to allow null values for the values above, it's certain that some of our users have gotten used to calling certain methods with these values unspecified (null). I'm taking back whatever I said in my posts earlier, but to continue offering this flexibility, we should probably edit the The other alternative is to not allow null values to be accepted anywhere (including the API server) anymore so that we don't have to deal with such cases anymore. To avoid existing users being interrupted, we can simply ensure that exposed methods on the SDK properly set default values and not allow the SDK to send null values to the API server (by updating the OpenAPI specs). I'm sitting on the fence for these two options, so I'm okay with either of these really (please share any opinions any of you have on this). API Server
To keep things clean, I suggest we remove the DBBoth
With such a variety of ways these values are stored in the DB, for simplicity and clarity, I suggest that we perform a migration to correct these values to make them defined once and for good. These are the SQL commands we can perform to migrate each of the locations where the values above can be found:
|
Once we update all the records in DB, I think we don't need to change the OpenAPI spec (accepting empty string value as enum). In SDK we need to populate the default if it is not supplied by user ( I think this is already implemented). I think in API server we already implement the default value if the deployment mode or protocol is empty, the reasoning why we still accept empty string value is to maintain backward compatibility for older sdk that doesn't pass those information |
Sounds good, let's keep the OpenAPI spec as it is then after updating all the records in the DB :) Thanks a lot for sharing your input on this! |
I dont think we should support So if we do the db migration manually, can i confirm that we dont need this PR? |
I don't have strong opinion on this, both is okay
Yup, correct. I can close this if we are agree to do it manually |
Yep, we will do the db migration manually it in the upcoming release. Trying to keep db-migration to what is really needed only, else it will hit 100 scripts soon and become a pain to manage |
Description
Version endpoints and model endpoints that are deployed before
protocol
is introduced will have empty string ornull
value. This will be a problem when new SDK is published, the new SDK has strict validation regarding the enum value and type of each response from server. For empty string value of protocol in old model(version) endpoints, the new SDK will return error since the acceptable value for protocol isUPI_V1
andHTTP_JSON
, hence this PR will add default value for protocol to reduce this issue arise in the future.Also this PR will relax the enum for
DeploymentMode
andProtocol
so it can accept empty string as enum value. This is to reduce chances error during deserialize model API response that containing model endpoints rule that has version_endpoints data with empty protocol or deployment mode. Modifying model endpoint rule by using sql will require complex jsonb query hence for now we just relax the enum valueModifications
Add database script to update protocol default value for model_endpoints and version_endpoints
Tests
Checklist
Release Notes