pulumi/pulumi · error
unknown visibility: %q
Error message
unknown visibility: %q
What it means
Package visibility is an enum restricted to "public" or "private". The Visibility UnmarshalText method validates any incoming visibility string against those two values and throws this error otherwise. It exists to keep visibility metadata canonical so downstream access-control logic can rely on the parsed value.
Source
Thrown at sdk/go/common/apitype/package.go:210
return "<empty>"
}
return v.status
}
func (v Visibility) MarshalJSON() ([]byte, error) {
return json.Marshal(v.status)
}
func (v *Visibility) UnmarshalJSON(data []byte) error {
var status string
if err := json.Unmarshal(data, &status); err != nil {
return err
}
switch status {
case VisibilityPublic.status, VisibilityPrivate.status:
*v = Visibility{status}
default:
return fmt.Errorf("unknown visibility: %q", status)
}
return nil
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Change the visibility value to exactly "public" or "private"
- Trim whitespace and match lowercase spelling
- Upgrade the SDK if the publisher legitimately introduced a new visibility level
Example fix
// before
{"visibility": "internal"}
// after
{"visibility": "private"} Defensive patterns
Strategy: validation
Validate before calling
func validVisibility(s string) bool {
return s == "public" || s == "private"
} Try / catch
var v apitype.Visibility
if err := v.UnmarshalText([]byte(raw)); err != nil {
return fmt.Errorf("bad visibility %q: %w", raw, err)
} Prevention
- Use VisibilityPublic/VisibilityPrivate constants, never raw strings
- Normalize external visibility values (lowercase, trim) before unmarshal
- Check package metadata with a JSON schema in CI
When it happens
Trigger: Unmarshaling package metadata JSON where the visibility field holds a string other than "public" or "private" (typo, different casing, or an invented value like "internal").
Common situations: Hand-editing package.json-style metadata; migrating from another registry format that uses different visibility vocabulary; publishing tooling emitting a new visibility level the SDK doesn't know.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- unknown package status: %q
- minVersion must be >= 1, got %d
- maxVersion (%d) must be >= minVersion (%d)
- defaultVersion (%d) must be in [minVersion, maxVersion] = [%
- shell extra root %q is not a directory
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/98ef821b3960660b.
Report an issue: GitHub.