-
Notifications
You must be signed in to change notification settings - Fork 68
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
[SYNPY-1513] Validate input submission ID in getSubmission(...)
#1135
Conversation
Hello @jaymedina! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-10-01 13:47:24 UTC |
Hey @BryanFauble @thomasyu888 , before I move forward with this solution I'd like to run it by you both since it is a breaking change (see latest tests) and involves a little bit of re-structuring everywhere where Thanks! |
The issue with this is that is we might not know ahead of time if an ID is for an entity is a File, or some other entity in Synapse. Take the example where I tested out the dot notation with a project, and it seems like on the backend these entities do have a version applied to them, but it can only ever be version 1, "syn54022402.2" fails:
I think at the moment it just makes sense to worry about what's in front of us and only update Should Synapse itself should be performing this data check? |
That's a really good point @BryanFauble and I guess it depends on the scope of responsibility within synpy. Is the current expectation when we develop on this client that synpy validates inputs before communicating with the API or do we leave that responsibility with the API to handle these cases (in this context, a submission ID having a decimal)? Validating on the synpy side feels more flexible and would prevent unnecessary communications with the Synapse API, but also adds complexity to the codebase like what's going to be in this PR. Right now I lean towards keeping small validation logic like this in synpy (under If we go with handling the inputs on the client side, I would go back to my previous solution of handling the submission IDs with a new function in |
It's important for both. Think about the client/server relationship as it pertains to a Web UI and a backend server. The UI can have input validation, but the server needs to have that final strict enforcement of the rules.
I agree that we can handle this client side. There are a bunch of these similar checks in the code base already - For example making sure that an entity ID starts as
I agree that this should be a new function, since the rules for a submission ID are different from those of an entity/synapse ID. |
08fc8d0
to
390c6ca
Compare
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.
🔥 LGTM! I'll leave it to @BryanFauble for final review.
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.
This is great! Thanks for the thorough tests!
problem
The endpoint
evaluation/submission/{id}
was receiving communications with submission IDs that had decimal points in them (e.g.123.0
). This was obstructing an ingestion process in Snowflake, and should not exist in the first place. Submission IDs are not ID types that support decimal points.solution
In
getSubmission(...)
and other related methods inclient.py
, theid_of(...)
method fromutils.py
is utilized to retrieve a valid entity ID. This method was being used for submission IDs, but was effectively useless, as it would just return the same string object or numbers object (as a string) without verifying its format.The solution involves creating a separate method called
validate_submission_id
and replacingid_of
with it, to enforce the no-decimal rule in the input.utils.validate_submission_id
to handle decimals in input IDstesting
Test
getSubmission
Test
getSubmissionStatus