Skip to content

Conversation

@bgardiner
Copy link
Contributor

@bgardiner bgardiner commented Dec 2, 2025

Summary

The projectName field in the JSON output of snyk container monitor --json contains the monitor's public ID (UUID) instead of the actual project name.

Changes

File: src/lib/ecosystems/monitor.ts

Changed line 214 from:

projectName: monitorResult.id,

to:

projectName: monitorResult.projectName,

Root Cause

The registry correctly returns projectName: project.name in the MonitorDependenciesResponse, but the CLI was overwriting it with monitorResult.id when building the JSON output.

Breaking Change Consideration

This is changing the JSON response of a CLI command, so it should be assessed for breaking change. I do NOT think it qualifies as a breaking change. The return type (string) and field key remain the same. The previous field value returned something completely unusable by the user (the monitor's public ID), as there is no public API call that references the monitor ID. This corrects a bug and should NOT negatively impact customer's existing use of the monitor command.

Steps to Reproduce (before fix)

snyk container monitor --json alpine:latest | jq '.projectName, .scanResult.name'

Output before fix:

"bcc57aaa-4415-4806-b2a4-4dd088f2c53b"   # projectName (wrong - this is monitor.publicId)
null                                       # scanResult.name

Expected output after fix:
projectName should contain the project's display name (e.g., automatically determined value from the image name or the value passed via --project-name).

@bgardiner bgardiner requested review from a team as code owners December 2, 2025 16:09
@bgardiner bgardiner marked this pull request as draft December 2, 2025 16:09
@bgardiner bgardiner force-pushed the fix/container-monitor-json-projectname branch 2 times, most recently from 0323e7e to 6d0e892 Compare December 2, 2025 19:55
The projectName field in 'snyk container monitor --json' output was
incorrectly set to monitorResult.id (the monitor's public ID) instead
of monitorResult.projectName (the actual project name).

This caused the JSON output to display a UUID instead of the project's
display name (e.g., the image name or --project-name value).

Changes:
- Fixed src/lib/ecosystems/monitor.ts line 214 to use monitorResult.projectName
- Added unit test with mocked registry response to validate the fix
- Updated acceptance tests with correct expected projectName values
@bgardiner bgardiner force-pushed the fix/container-monitor-json-projectname branch from 192702e to 48e3995 Compare December 3, 2025 14:30
@bgardiner bgardiner marked this pull request as ready for review December 4, 2025 20:19
data: monOutput,
path: monitorResult.path,
projectName: monitorResult.id,
projectName: monitorResult.projectName,
Copy link
Contributor

Choose a reason for hiding this comment

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

changes look good. I have only one question, do you think having the a non unique project name reported for base image/ application project could break any automation around the json output?
Current behavior: json output for node:lates
cat json_output | jq '.[].projectName' "bae0b739-9d1c-4e04-99ac-3e7af3faa271" "73e39537-0bf5-45ed-9621-06d83dc9d69f"

the projectName will be same for both projects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should not actually be the same projectName for both projects. One will have a target file appended. For example, when setting --project-name=brians_project on a container with a JS application, there are two different projects created:

  • brians_project:/usr/lib/node_modules (JS app)
  • brians_project (base image)

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.

3 participants