Skip to content

fix: enhance validations in loadRawScoreFiles to check for missing metadata#498

Open
ShantKhatri wants to merge 1 commit into
score-spec:mainfrom
ShantKhatri:fix/issue-492
Open

fix: enhance validations in loadRawScoreFiles to check for missing metadata#498
ShantKhatri wants to merge 1 commit into
score-spec:mainfrom
ShantKhatri:fix/issue-492

Conversation

@ShantKhatri
Copy link
Copy Markdown

Description

This PR refactors loadRawScoreFiles() to accumulate and report all validation errors together. This prevents the silent overwriting of Score files when multiple files have missing or invalid metadata, and provides users with a complete picture of all problems in their input files before re-running the command.

What does this PR do?

Fixes #492
When multiple Score files were provided and some (or all) lacked required metadata, the loader would silently overwrite entries under the empty workload key "", with only the last invalid file being reported in the error message. This hide the existence of earlier invalid files from users.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

…tadata

Signed-off-by: Prashantkumar Khatri <prashantkhatri202@gmail.com>
Signed-off-by: Prashantkumar Khatri <khatri2105104@st.jmi.ac.in>
@ShantKhatri
Copy link
Copy Markdown
Author

Hi @mathieu-benoit , Here's the output on my local after the fix:
Screenshot from 2026-05-28 21-19-04
Both files are now reported correctly instead of silently dropping one. Happy to hear any feedback or suggestions on this!

@mathieu-benoit
Copy link
Copy Markdown
Contributor

Thanks, @ShantKhatri!

While here, I'm just wondering what do you @ShantKhatri @chris-stephenson think if this goes to score-go in this common Validate() function? https://github.com/score-spec/score-go/blob/main/loader/validate.go#L125

@ShantKhatri
Copy link
Copy Markdown
Author

Thanks, @ShantKhatri!

While here, I'm just wondering what do you @ShantKhatri @chris-stephenson think if this goes to score-go in this common Validate() function? https://github.com/score-spec/score-go/blob/main/loader/validate.go#L125

Good point! The fix in loadRawScoreFiles needs to stay in both repos regardless since Validate() runs after the map is already built, so the silent overwrite has already happened by then.

Also, practically, the JSON schema already enforces metadata.name as required, so Validate() would never actually see an empty name in the normal flow anyway. The only case it'd help is someone calling Validate() directly without schema validation, which is a pretty narrow use case. Adding it to Validate() makes sense as an extra layer for future Score implementations using score-go directly, but it can't replace the file-level fix.

So, score-compose and score-k8s PRs are the real fix. We can move with a separate score-go PR after those land if we want the extra layer.

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.

[bug] Silent Workload Drop on Missing Metadata (Map Key Overwrite)

2 participants