siyuan-note/siyuan · error

inline styles file exceeds the

Error message

inline styles file exceeds the %d byte limit

What it means

The persisted inline styles file has a hard size limit (maxInlineStylesFileSize). After marshalling, if the serialized document exceeds that byte count, the write is refused so the storage file cannot grow unbounded or slow down every load.

Solutions

  1. Prune unused or duplicate custom styles/colors before calling the API and retry.
  2. Batch updates: send one consolidated styles document instead of many incremental additions.
  3. Check the current file size (storage/inline styles path via inlineStylesPath) and reclaim space by removing stale entries.
Defensive patterns

Strategy: validation

Validate before calling

data, _ := json.MarshalIndent(styles, "", "  ")
if len(data) > maxInlineStylesFileSize {
    // prune unused styles/colors before calling the API
}

Try / catch

if err != nil && strings.Contains(err.Error(), "byte limit") {
    // prune and retry with a smaller document
}

Prevention

When it happens

Trigger: SetInlineStyles / SetWorkspaceAVPalette adding custom styles or palette colors until the marshalled JSON exceeds maxInlineStylesFileSize bytes.

Common situations: Programmatic bulk import of hundreds of custom colors/styles; a plugin repeatedly appending palette entries without removing unused ones; a long-lived workspace accumulating orphaned style definitions.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/inline_style.go:282

		if err != nil {
			return nil, false, err
		}
		for _, avID := range sortedAttributeViewUsageIDs(customColorUsage) {
			indexes := customColorUsage[avID]
			for index := range removedIndexes {
				if _, used := indexes[index]; used {
					return nil, false, fmt.Errorf("attribute view custom color [%d] is still in use by attribute view [%s]",
						index, avID)
				}
			}
		}
	}
	data, err := gulu.JSON.MarshalIndentJSON(ret, "", "  ")
	if err != nil {
		return nil, false, fmt.Errorf("marshal inline styles failed: %w", err)
	}
	if maxInlineStylesFileSize < len(data) {
		return nil, false, fmt.Errorf("inline styles file exceeds the %d byte limit", maxInlineStylesFileSize)
	}

	dataPath := inlineStylesPath()
	oldData, readErr := filelock.ReadFile(dataPath)
	if readErr != nil && !os.IsNotExist(readErr) {
		return nil, false, fmt.Errorf("read inline styles failed: %w", readErr)
	}
	if bytes.Equal(oldData, data) {
		cacheWorkspaceAVPalette(ret.AV)
		return ret, false, nil
	}

	if err = os.MkdirAll(filepath.Dir(dataPath), 0755); err != nil {
		return nil, false, fmt.Errorf("create inline styles directory failed: %w", err)
	}
	if err = filelock.WriteFile(dataPath, data); err != nil {
		return nil, false, fmt.Errorf("write inline styles failed: %w", err)
	}

View on GitHub (pinned to 9f775e8a12)