siyuan-note/siyuan · error
Field [conf] should be of type [Object]
Error message
Field [conf] should be of type [Object]
What it means
GraphConfiguration.UnmarshalJSON rejects any payload whose top-level JSON value is not a JSON object. The field being decoded is named `conf`, so when the raw bytes cannot be decoded into map[string]json.RawMessage (e.g. the caller sent a string, number, array, or malformed JSON), the decoder reports that `conf` must be an Object. This keeps the graph configuration contract strict: configuration is always a keyed object, never a scalar or list.
Solutions
- Send `conf` as a JSON object, e.g. {"conf": {"key": "value"}}
- If you serialized the config in your client, make sure it was not JSON.stringify-ed twice (string instead of object)
- Validate the request body parses as JSON before sending
- Use {} for an empty graph configuration instead of [] or ""
Example fix
// before
{"conf": "{\"local\":\"true\"}"}
// after
{"conf": {"local": "true"}} Defensive patterns
Strategy: validation
Validate before calling
const conf = body.conf;
if (typeof conf !== "object" || conf === null || Array.isArray(conf)) {
throw new Error("conf must be a plain JSON object");
} Type guard
const isPlainObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
Prevention
- Never double-serialize config objects with JSON.stringify before embedding them in a payload
- Use {} for empty configs
- Lint request-building code so conf is always an object literal
When it happens
Trigger: Posting a graph configuration (e.g. to the graph-related kernel endpoints, or decoding a payload containing `conf`) where the `conf` value is a JSON string, number, array, boolean, or the whole body is not an object; also thrown for `null` only with a different message, so this one specifically means a non-object non-null value or syntactically invalid JSON.
Common situations: Clients quoting the config object as a string (double-encoded JSON), sending `[]` instead of `{}` as an empty config, or hand-built request bodies with a typo that breaks JSON parsing.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5b865552e01da13d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/apicontract/graph_input.go:20
import (
"bytes"
"encoding/json"
"fmt"
"io"
"strings"
)
// GraphConfiguration 延迟绑定具体图配置,使局部图继续忽略全局图字段,并保留默认值合并顺序。
type GraphConfiguration struct{ raw json.RawMessage }
func (c *GraphConfiguration) UnmarshalJSON(data []byte) error {
if bytes.Equal(bytes.TrimSpace(data), []byte("null")) {
return fmt.Errorf("Field [conf] is required")
}
fields, err := legacyJSONValue[map[string]json.RawMessage](data)
if err != nil {
return fmt.Errorf("Field [conf] should be of type [Object]")
}
c.raw, err = json.Marshal(fields)
return err
}
func (c GraphConfiguration) MarshalJSON() ([]byte, error) {
if len(c.raw) == 0 {
return []byte("{}"), nil
}
return c.raw, nil
}
type GraphConfigurationFields struct {
MinRefs *int `json:"minRefs" api:"optional"`
DailyNote *bool `json:"dailyNote" api:"optional"`
Type *GraphTypeFilter `json:"type" api:"optional"`
D3 *GraphD3 `json:"d3" api:"optional"`
}View on GitHub (pinned to 9f775e8a12)