Repository navigation
fix(api): 404/400 for unknown REST ids; refuse blank and duplicate AI model version labels - #359
Merged
Merged
Conversation
Several REST routes answered 500, or 200 with an error text, when given an id they could not use (#351): - /api/aimodels/<id>/ (and call/, call-async/) take the id as a string, but AIModel has an integer key, so a non-numeric id or a UUID raised ValueError and became a 500 (or a 400 on call/). Treat an id that can't be a key like an unknown one: 404. The route stays a plain string so it survives a future key type change. - /api/download/chart/<id> answered a missing chart with a plain-text 200. - /api/download/access_resource/<id> was routed but never handled, so it fell through to a 200 "Invalid type". Drop it from the route. - /api/generate-dynamic-chart/<id> let an unknown column, invalid JSON or malformed options escape as 500s; these are client errors, so answer 400. Closes #351
createAiModelVersion saved the label as sent, so an empty version was stored. A label the model already had hit the unique rule, whose error format_integrity_error split into a bogus field name, leaving nonFieldErrors null and showing the user nothing (#349). Both create and update now trim the label and refuse a blank one or one another version of the model has, with a message in nonFieldErrors, before anything is saved. An update may resend a label that is already blank so older rows stay editable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #351
Closes #349
Two independent fixes, one commit each.
REST routes answer 404/400 for unknown or malformed ids (#351)
Several REST routes answered 500, or 200 with an error text, for ids they couldn't use:
/api/aimodels/<id>/(andcall/,call-async/): a non-numeric id or a UUID raisedValueErrorand became a 500 (or a 400 oncall/). An id that can't be a key is now treated like an unknown one: 404. The route stays a plain string so it survives a future key type change./api/download/chart/<id>: answered a missing chart with a plain-text 200. It now answers 404./api/download/access_resource/<id>: was routed but never handled, so it fell through to a 200 "Invalid type". It's dropped from the route./api/generate-dynamic-chart/<id>: an unknown column, invalid JSON or malformed options escaped as 500s. These are client errors, so they now answer 400.Tests:
tests/test_rest_unknown_ids.pycreateAiModelVersion refuses blank and duplicate labels (#349)
createAiModelVersionsaved the label as sent, so an empty version was stored. A label the model already had broke the unique constraint, but the error named no field, sononFieldErrorswas null and the user saw nothing.Create and update now trim the label and refuse a blank one, or one another version of the model already has, with a message in
nonFieldErrors, before anything is saved. An update may resend a label that is already blank, so older rows stay editable. The wizard side is DataSpaceFrontend#530.Tests:
tests/schema/test_aimodel_version_label.pyMerge note
This branch is 12 commits behind
dev.api/schema/aimodel_schema.pyconflicts with #348's fix (e8ca126) in one import list:devaddsMAX_RETRIES_RANGE, and this branch addsblank_error. The resolution keeps both.🤖 Generated with Claude Code