siyuan-note/siyuan · error

invalid layer fit [ ]

Error message

invalid layer fit [%s]

What it means

Each layer's fit describes how the media fills the boot screen (defaulting to "cover" when empty). If the resolved fit is not one of the values accepted by isValidBootAppearanceFit, the kernel rejects the manifest with this error.

Solutions

  1. Set layer "fit" to one of the kernel-accepted values (see isValidBootAppearanceFit in kernel/model/boot_appearance.go, e.g. cover/contain/fill).
  2. Remove the "fit" field entirely to get the default "cover" behavior.
  3. Fix casing/typos so the value matches the whitelist exactly (lowercase).

Example fix

// before: manifest.json
{"id":"bg","type":"image","src":"bg.png","fit":"Cover"}
// after
{"id":"bg","type":"image","src":"bg.png","fit":"cover"}
Defensive patterns

Strategy: validation

Validate before calling

const FITS = ['cover', 'contain', 'fill']; // mirror isValidBootAppearanceFit
for (const l of manifest.layers) {
  const fit = l.fit || 'cover';
  if (!FITS.includes(fit)) throw new Error(`invalid layer fit: ${fit}`);
}

Type guard

function hasValidFit(l) { const f = l.fit || 'cover'; return ['cover', 'contain', 'fill'].includes(f); }

Try / catch

try { loadAppearance(id); } catch (e) { if (/invalid layer fit/.test(String(e))) { /* correct or remove the fit field */ } }

Prevention

When it happens

Trigger: A manifest.json layer sets "fit" to a value outside the accepted set (e.g. "fill-stretch", "100%", "Cover" with a capital letter, or a CSS object-fit-like value the kernel does not whitelist).

Common situations: Author copying CSS object-fit values that the kernel does not support; wrong casing; inventing a fit mode hoping it maps to CSS; manifest edited by hand with a typo such as "covert".

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


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/9c665ca659bae381. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/boot_appearance.go:484

		}
		if layer.Type == "video" {
			if layer.Poster == "" {
				err = errors.New("video poster is required")
				return nil, err
			}
			if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Poster, "image"); err != nil {
				return nil, fmt.Errorf("invalid video poster: %w", err)
			}
		} else if layer.Poster != "" {
			err = errors.New("image layer cannot declare a poster")
			return nil, err
		}
		fit := layer.Fit
		if fit == "" {
			fit = "cover"
		}
		if !isValidBootAppearanceFit(fit) {
			err = fmt.Errorf("invalid layer fit [%s]", fit)
			return nil, err
		}
		position := layer.Position
		if position == "" {
			position = "center"
		}
		if !isValidBootAppearancePosition(position) {
			err = fmt.Errorf("invalid layer position [%s]", position)
			return nil, err
		}
		item := &BootAppearanceLayer{
			ID:       layer.ID,
			Type:     layer.Type,
			Src:      bootAppearanceAssetURL(pkg.Name, appearanceID, layer.Src),
			Fit:      fit,
			Position: position,
		}
		if layer.Poster != "" {

View on GitHub (pinned to 9f775e8a12)