Skip to content

fix(preprod): Skip strict jsonschema for snapshot image metadata#115720

Merged
runningcode merged 3 commits into
masterfrom
no/skip-strict-image-jsonschema
May 18, 2026
Merged

fix(preprod): Skip strict jsonschema for snapshot image metadata#115720
runningcode merged 3 commits into
masterfrom
no/skip-strict-image-jsonschema

Conversation

@runningcode
Copy link
Copy Markdown
Contributor

Summary

  • Removes strict ImageMetadata.schema() from the jsonschema validation for image entries — replaces with additionalProperties: True
  • Top-level fields (app_id, VCS fields, selective, etc.) are still validated by jsonschema
  • Image metadata validation is handled by Pydantic when constructing the SnapshotManifest, which already coerces types and allows extra fields
  • Catches pydantic.ValidationError and returns a 400 with a useful message instead of letting it become a 500

Depends on #115710

Fixes EME-1156

Sidecar JSON files can contain boolean or numeric values in tags
(e.g., "show_background": true). The JSON Schema was rejecting these
with "True is not of type 'string'".

Relax the tags JSON Schema to accept any object (not just string
values), and coerce all tag values to strings in the Pydantic
validator so downstream code sees a consistent dict[str, str].

EME-1156
Let Pydantic handle image metadata validation instead of rejecting
requests upfront with jsonschema. Sidecar JSON files can contain
any types, and Pydantic already coerces values appropriately.

The jsonschema still validates the top-level structure (app_id, VCS
fields, etc.). Pydantic ValidationError is caught and returned as
a 400 instead of becoming a 500.

EME-1156
@runningcode runningcode requested a review from a team as a code owner May 18, 2026 12:51
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 18, 2026

EME-1156

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 18, 2026
Comment thread src/sentry/preprod/api/endpoints/snapshots/preprod_artifact_snapshot.py Outdated
Comment thread src/sentry/preprod/api/endpoints/snapshots/preprod_artifact_snapshot.py Outdated
Move Pydantic SnapshotManifest validation before the atomic block
so that a ValidationError returns 400 without committing orphaned
PreprodArtifact and PreprodSnapshotMetrics rows.
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3f65e84. Configure here.

@runningcode runningcode enabled auto-merge (squash) May 18, 2026 16:24
@runningcode runningcode merged commit ddb712e into master May 18, 2026
63 checks passed
@runningcode runningcode deleted the no/skip-strict-image-jsonschema branch May 18, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants