siyuan-note/siyuan · error

invalid style

Error message

invalid style: %w

What it means

When the manifest declares a "style" (custom CSS resource), loadBootAppearance validates it with validateBootAppearanceResource, which checks the path resolves safely inside the appearance directory, exists, and matches the expected resource type ("style"). Any failure is wrapped as "invalid style". This prevents path traversal, missing files, and wrong file kinds.

Solutions

  1. Ensure the file named in "style" exists inside the appearance directory and is committed/packaged with the plugin.
  2. Make "style" a relative path with no "..", symlinks, or absolute segments.
  3. Use a supported stylesheet extension (e.g. .css) for the style resource.
  4. Set "style" to "" in the manifest if no custom stylesheet is intended.

Example fix

// before: manifest.json
"style": "../shared/theme.css"
// after
"style": "theme.css"  // file present in the appearance directory
Defensive patterns

Strategy: validation

Validate before calling

const p = path.resolve(appearanceDir, manifest.style);
if (!p.startsWith(path.resolve(appearanceDir) + path.sep)) throw new Error('style escapes appearance dir');
if (!fs.existsSync(p)) throw new Error('style file missing: ' + manifest.style);

Try / catch

try { loadAppearance(id); } catch (e) { if (/invalid style/.test(String(e))) { /* check style path existence and containment */ } }

Prevention

When it happens

Trigger: manifest.json has a non-empty "style" field but the referenced file does not exist in the appearance directory, is a symlink or escapes the directory, has an extension not accepted for style resources, or exceeds size limits.

Common situations: Typo in the style file name in the manifest; style file forgotten when packaging the plugin; path written with "../" or an absolute path; style shipped as a different file type (e.g. .less instead of .css).

Understand the failure class

Background: Path traversal blocked: "path escapes the workspace" and "outside site root" errors when a path will not stay inside its allowed directory — this error's family across 26 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/boot_appearance.go:448

	if manifest.OfficialUI.ShowLogo != nil {
		ret.OfficialUI.ShowLogo = *manifest.OfficialUI.ShowLogo
	}
	if manifest.OfficialUI.ShowDetails != nil {
		ret.OfficialUI.ShowDetails = *manifest.OfficialUI.ShowDetails
	}
	for _, color := range []string{manifest.OfficialUI.TextColor, manifest.OfficialUI.ProgressColor,
		manifest.OfficialUI.TrackColor} {
		if err = validateOptionalBootAppearanceColor(color); err != nil {
			return nil, err
		}
	}
	ret.OfficialUI.TextColor = manifest.OfficialUI.TextColor
	ret.OfficialUI.ProgressColor = manifest.OfficialUI.ProgressColor
	ret.OfficialUI.TrackColor = manifest.OfficialUI.TrackColor

	if manifest.Style != "" {
		if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, manifest.Style, "style"); err != nil {
			return nil, fmt.Errorf("invalid style: %w", err)
		}
		ret.Style = bootAppearanceAssetURL(pkg.Name, appearanceID, manifest.Style)
	}

	layerIDs := map[string]bool{}
	for _, layer := range manifest.Layers {
		if layer == nil || !isValidBootAppearanceID(layer.ID) || layerIDs[layer.ID] {
			err = errors.New("invalid or duplicate layer ID")
			return nil, err
		}
		layerIDs[layer.ID] = true
		if layer.Type != "image" && layer.Type != "video" {
			err = fmt.Errorf("unsupported layer type [%s]", layer.Type)
			return nil, err
		}
		if _, _, err = validateBootAppearanceResource(pluginDir, appearanceDir, layer.Src, layer.Type); err != nil {
			return nil, fmt.Errorf("invalid layer source: %w", err)
		}

View on GitHub (pinned to 9f775e8a12)