hashicorp/packer · error
unsupported scope: %s (supported: squashed, all-layers)
Error message
unsupported scope: %s (supported: squashed, all-layers)
What it means
ParseScopeFromArgs accepts only 'squashed', 'all-layers', plus aliases 'all' and 'alllayers' (after lowercasing/trimming). Anything else returns `unsupported scope: %s (supported: squashed, all-layers)`. Scope controls whether Syft catalogs the merged image filesystem or every layer.
Source
Thrown at internal/sbom/generator.go:75
return FormatCycloneDX, nil
}
if strings.Contains(formatArg, "spdx") {
return FormatSPDX, nil
}
return "", fmt.Errorf("unsupported format: %s", formatArg)
}
func ParseScopeFromArgs(scopeArg string) (string, error) {
scopeArg = strings.ToLower(strings.TrimSpace(scopeArg))
switch scopeArg {
case ScopeSquashed:
return ScopeSquashed, nil
case ScopeAllLayers, "all", "alllayers":
return ScopeAllLayers, nil
default:
return "", fmt.Errorf("unsupported scope: %s (supported: squashed, all-layers)", scopeArg)
}
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Pass exactly "squashed" or "all-layers" (aliases "all" and "alllayers" also work)
- Rely on the empty-string default: NewGenerator sets ScopeSquashed when Scope is empty
- Read the error's supported list and correct the spelling/hyphenation
- Validate scope at config-parse time rather than at generate time
Example fix
// before
scope, err := sbom.ParseScopeFromArgs("all layers")
// after
scope, err := sbom.ParseScopeFromArgs("all-layers") Defensive patterns
Strategy: validation
Validate before calling
scope, err := sbom.ParseScopeFromArgs(scopeArg)
if err != nil {
return fmt.Errorf("invalid SBOM scope %q: %w", scopeArg, err)
} Type guard
func isSupportedScope(s string) bool {
switch strings.ToLower(strings.TrimSpace(s)) {
case "squashed", "all-layers", "all", "alllayers", "": return true
}
return false
} Try / catch
scope, err := sbom.ParseScopeFromArgs(arg)
if err != nil {
return fmt.Errorf("scope must be squashed or all-layers: %w", err)
} Prevention
- Validate scope strings at config parse time
- Leave Scope empty to inherit the squashed default
- Do not copy scope names from trivy/grype; they differ
When it happens
Trigger: Calling ParseScopeFromArgs("all layers"), ("squashed-layers"), ("directory"), or empty-but-set odd values like "squashed " trimmed fine, but "SquashedLayers" fails.
Common situations: Copying scope flags from other tools (trivy/grype use different names); typos like "all-layerss"; expecting syft's multi-value scope syntax; blank config strings from env vars that bypass NewGenerator defaults.
Related errors
- unsupported format: %s
- unsupported scope: %s
- unsupported format: %s (supported: cyclonedx, spdx)
- The `bucket_name` must be specified
- `channel` is currently a required field.
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/78559b4fb4326a6b.
Report an issue: GitHub.