Skip to content

Upload image metadata json data as part of snapshots job#3163

Open
rbro112 wants to merge 2 commits intomasterfrom
ryan/upload_image_metadata_json_data_as_part_of_snapshots_job
Open

Upload image metadata json data as part of snapshots job#3163
rbro112 wants to merge 2 commits intomasterfrom
ryan/upload_image_metadata_json_data_as_part_of_snapshots_job

Conversation

@rbro112
Copy link
Member

@rbro112 rbro112 commented Feb 27, 2026

Description

Issues

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@rbro112 rbro112 requested review from a team and szokeasaurusrex as code owners February 27, 2026 19:43
Copy link
Member Author

rbro112 commented Feb 27, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Upload image metadata json data as part of snapshots job ([#3163](https://github.com/getsentry/sentry-cli/pull/3163))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against ef67db9

Comment on lines 341 to 343
let matched = manifest_entries
.values_mut()
.find(|entry| entry.image_file_name == json_image.image_file_name);
Copy link

Choose a reason for hiding this comment

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

Bug: When multiple images share the same filename in different directories, metadata from the manifest is only applied to the first one found, silently ignoring the others.
Severity: MEDIUM

Suggested Fix

Modify the matching logic to either use the full relative path for unique identification or iterate through and apply metadata to all images that match the given filename, not just the first one.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/commands/build/snapshots.rs#L341-L343

Potential issue: The `merge_manifest_metadata` function matches images from a JSON
manifest using only the filename, not the full relative path. If multiple images in
different subdirectories share the same filename (e.g., `ios/screenshot.png` and
`android/screenshot.png`), the logic uses `.find()` which only returns the first match.
As a result, metadata from the manifest is only applied to the first image found, and
any other images with the same filename are silently ignored, leading to inconsistent
metadata application without any warning or error.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 37 to 38
pub struct SnapshotManifestFile {
pub images: HashMap<String, ImageMetadata>,
Copy link

Choose a reason for hiding this comment

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

Bug: The JSON manifest requires redundant width and height fields. If omitted, the entire manifest is silently ignored, and no metadata is applied.
Severity: HIGH

Suggested Fix

Make the width and height fields in the ImageMetadata struct optional for deserialization. This can be achieved by changing their types to Option<u32> or by using #[serde(default)].

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/api/data_types/snapshots.rs#L37-L38

Potential issue: The `ImageMetadata` struct, used for deserializing the JSON manifest,
requires `width` and `height` fields. However, these values are never used, as the
application extracts dimensions directly from the image files. If a user omits these
redundant fields from the JSON manifest, deserialization fails, and the entire manifest
is silently ignored with only a warning log. This prevents any intended metadata, such
as `display_name`, from being applied, making the feature appear broken to the user.

Did we get this right? 👍 / 👎 to inform future reviews.

Comment on lines 251 to +254
.unwrap_or_default()
.to_string_lossy()
.into_owned();
let display_name = display_names.get(&image_file_name).cloned();
Copy link

Choose a reason for hiding this comment

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

Bug: The code uses only the filename to look up an image's display name, but the manifest is keyed by the full relative path, causing lookups for images in subdirectories to fail silently.
Severity: MEDIUM

Suggested Fix

Use the full image.relative_path as a string when performing the lookup in the display_names map. Do not call .file_name() on the path, as this discards the subdirectory information needed to find a match.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/commands/build/snapshots.rs#L251-L254

Potential issue: When discovering images, the code correctly identifies a relative path
like `ui/button.png`. However, to look up the corresponding `display_name` from the
manifest, it extracts only the filename (`button.png`) using `.file_name()`. The
manifest data, stored in the `display_names` map, is keyed by the full relative path
provided by the user. This key mismatch causes the lookup to silently fail. As a result,
the `display_name` is omitted from the uploaded metadata for any images organized in
subdirectories, even when correctly specified by the user.

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