{"record":{"id":"e8bbb517d70445ae","repo":"siyuan-note/siyuan","slug":"unsupported-inline-styles-version","errorCode":null,"errorMessage":"unsupported inline styles version","messagePattern":"unsupported inline styles version","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/apicontract/inline_style_input.go","lineNumber":72,"sourceCode":"func init() {\n\tSetInlineStyles.decodeRequest = func(reader io.Reader) (request SetInlineStylesRequest, err error) {\n\t\tfields, err := blockRequestFields(reader, \"/api/storage/setInlineStyles\")\n\t\tif err != nil {\n\t\t\treturn request, err\n\t\t}\n\t\tversion, err := legacyField[float64](fields, \"version\", \"Number\", true)\n\t\tif err != nil {\n\t\t\treturn request, err\n\t\t}\n\t\tif _, err = legacyField[[]json.RawMessage](fields, \"styles\", \"Array\", true); err != nil {\n\t\t\treturn request, err\n\t\t}\n\t\tapp, err := legacyField[string](fields, \"app\", \"String\", false)\n\t\tif err != nil {\n\t\t\treturn request, err\n\t\t}\n\t\tif version != 1 && version != 2 {\n\t\t\treturn request, errors.New(\"unsupported inline styles version\")\n\t\t}\n\t\tif version == 1 {\n\t\t\trequest.Styles, err = legacyJSONValue[[]*InlineStyle](fields[\"styles\"])\n\t\t} else {\n\t\t\tdata, marshalErr := json.Marshal(fields)\n\t\t\tif marshalErr != nil {\n\t\t\t\treturn request, marshalErr\n\t\t\t}\n\t\t\trequest, err = legacyJSONValue[SetInlineStylesRequest](data)\n\t\t}\n\t\trequest.Version, request.App = version, app\n\t\treturn\n\t}\n\tSetWorkspaceAVPalette.decodeRequest = func(reader io.Reader) (request WorkspaceAVPaletteRequest, err error) {\n\t\tfields, err := blockRequestFields(reader, \"/api/storage/setWorkspaceAVPalette\")\n\t\tif err != nil {\n\t\t\treturn request, err\n\t\t}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/apicontract/inline_style_input.go#L54-L90","documentation":"The inline-styles request decoder in the API contract layer only accepts protocol versions 1 and 2. When the decoded request carries a `version` field with any other value, decoding is aborted and this error is returned before any styles are applied. It exists to reject requests produced by newer (or corrupted/legacy) clients whose payload shape the server cannot safely interpret.","triggerScenarios":"Sending a kernel API request whose decoded fields include version != 1 and version != 2 (e.g. version=3 from a newer client, version=0 omitted/default, or a manually crafted payload with a string that decodes to an unexpected value).","commonSituations":"A frontend or plugin built against a newer inline-styles protocol calls an older kernel; a hand-written HTTP call omits the version field so it defaults to 0; payload got truncated or tampered with in a proxy.","solutions":["Set the request's version field to 1 (legacy []*InlineStyle styles) or 2 (current format).","Update the client so it matches the server's supported protocol version, or upgrade the kernel to accept the newer version.","Inspect the raw request body to confirm the version value is the integer 1 or 2 and not a string or missing field."],"exampleFix":"// before\n{\"app\": \"editor\", \"version\": 3, \"styles\": [...]}  // rejected\n// after\n{\"app\": \"editor\", \"version\": 2, \"styles\": [...]}","handlingStrategy":"validation","validationCode":"function checkInlineStyleVersion(payload) {\n  if (payload.version !== 1 && payload.version !== 2) {\n    throw new Error(\"version must be 1 or 2\");\n  }\n}","typeGuard":"function hasSupportedVersion(p) { return p.version === 1 || p.version === 2; }","tryCatchPattern":"try { await sendRequest(payload); } catch (e) { if (String(e).includes(\"unsupported inline styles version\")) { payload.version = 2; await sendRequest(payload); } else { throw e; } }","preventionTips":["Pin the protocol version constant shared between client and kernel.","Never omit the version field; always send it explicitly as an integer.","When upgrading clients, check the server's supported versions first."],"tags":["api","versioning","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}