Skip to content

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

@ShantKhatri

Description

@ShantKhatri

Describe the bug
The loading pattern in loadRawScoreFiles is:
https://github.com/score-spec/score-compose/blob/main/internal/command/generate.go#L447-L454

		if meta, ok := out["metadata"].(map[string]interface{}); ok {
			workloadName, _ = meta["name"].(string)
			if _, ok := workloadToRawScore[workloadName]; ok {
				return nil, nil, fmt.Errorf("workload name '%s' in file '%s' is used more than once", workloadName, fileName)
			}
		}
		workloadNames = append(workloadNames, workloadName)
		workloadToRawScore[workloadName] = out

Because the map-collision check is nested inside the if meta, ok block, if a Score file completely omits the metadata block, workloadName remains the initialized empty string "". If multiple files are processed and miss metadata, the collision check is bypassed entirely. The workloadToRawScore[""] key is simply overwritten with the last file processed, silently dropping all previous workloads.

To Reproduce
Steps to reproduce the behavior:
Run score-compose generate file1.yaml file2.yaml where both files completely omit the metadata block. The system will only process file2.yaml (overwriting file1.yaml silently) and will eventually fail validation on file2.yaml alone, completely hiding the existence of file1.yaml.

Expected behavior
The parser should immediately reject a workload without metadata, or at the very least, catch the collision on the empty string "" key and throw the duplicate workload name error.

Screenshots

Image

Desktop (please complete the following information):

  • OS: macOS
  • Version 26.4.1 (25E253)

Additional context
Was writing a batch of stubbed Score files to test how the CLI handles bulk multi-file generation before wiring up real container specs. Two of the stubs had no metadata block yet, one was silently dropped with zero output from the CLI. Only noticed because the final compose output had fewer services than expected.

Moving the collision check outside the if meta, ok block, or explicitly checking if workloadName == "" before map insertion, will prevent this overwrite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions