Skip to content

fix(preprod): Change snapshot image tags from list to dict#115643

Merged
NicoHinderling merged 5 commits into
masterfrom
snapshot-tags-to-dict
May 15, 2026
Merged

fix(preprod): Change snapshot image tags from list to dict#115643
NicoHinderling merged 5 commits into
masterfrom
snapshot-tags-to-dict

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented May 15, 2026

Summary

Changes the tags field on snapshot image metadata from list[str] to dict[str, str], enabling key-value tag semantics (e.g. {"theme": "dark"} instead of ["dark"]).

  • Updates ImageMetadata and SnapshotImageDetailImageInfo types from list[str] to dict[str, str]
  • Adds a Pydantic validator on ImageMetadata.tags to gracefully coerce legacy list payloads into dict form (["dark"] → {"dark": "dark"})
  • Adds test coverage for tag coercion edge cases (dict passthrough, list conversion, empty values, unexpected types)

This is a re-land of #115628, which was reverted and then re-applied with a test fix.

@NicoHinderling NicoHinderling requested a review from a team as a code owner May 15, 2026 16:31
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 15, 2026
@NicoHinderling NicoHinderling changed the title Snapshot tags to dict fix(preprod): Change snapshot image tags from list to dict May 15, 2026
Copy link
Copy Markdown
Contributor

@chromy chromy left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread src/sentry/preprod/snapshots/manifest.py
…tion

The JSON schema generated by ImageMetadata.schema() rejected list-format
tags before the Pydantic coerce_tags validator could run, breaking
backward compatibility for clients still sending tags as a list.

Add schema_extra to emit an anyOf that accepts both object and array
formats, so jsonschema.validate passes and the Pydantic validator handles
coercion.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
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 8e37f3a. Configure here.

Comment thread src/sentry/preprod/snapshots/manifest.py
The schema_extra override dropped the null type for the optional tags
field, causing jsonschema.validate to reject explicit "tags": null
payloads.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…xtra

Mypy strict mode requires explicit type parameters for generic types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NicoHinderling NicoHinderling enabled auto-merge (squash) May 15, 2026 18:56
@NicoHinderling NicoHinderling merged commit e2046a4 into master May 15, 2026
62 checks passed
@NicoHinderling NicoHinderling deleted the snapshot-tags-to-dict branch May 15, 2026 19:04
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