Skip to content

fix(api): 404/400 for unknown REST ids; refuse blank and duplicate AI model version labels - #359

Merged
amit0539 merged 3 commits into
devfrom
fix/rest-unknown-ids
Dec 3, 2026
Merged

amit0539 merged 3 commits into
devfrom
fix/rest-unknown-ids

Conversation

@amit0539

@amit0539 amit0539 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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>/ (and call/, call-async/): a non-numeric id or a UUID raised ValueError and became a 500 (or a 400 on call/). 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.py

createAiModelVersion refuses blank and duplicate labels (#349)

createAiModelVersion saved 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, so nonFieldErrors was 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.py

Merge note

This branch is 12 commits behind dev. api/schema/aimodel_schema.py conflicts with #348's fix (e8ca126) in one import list: dev adds MAX_RETRIES_RANGE, and this branch adds blank_error. The resolution keeps both.

🤖 Generated with Claude Code

amit0539 and others added 3 commits December 2, 2026 16:39
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.
@amit0539
amit0539 merged commit 2a499db into dev Dec 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant