siyuan-note/siyuan · error
Field [id] must not be empty
Error message
Field [id] must not be empty
What it means
The graph query decoder reads the `id` field as a required String via legacyField, trims it, and rejects an empty result. The identifier selects which graph configuration the query targets, so an empty id is meaningless and rejected with 'Field [id] must not be empty'.
Solutions
- Provide a valid non-empty id, e.g. {"id": "local"}
- Guard the caller: skip the API call when the id is empty
- Verify the value is not whitespace-only after trimming
Example fix
// before
{"id": "", "conf": {}}
// after
{"id": "local", "conf": {}} Defensive patterns
Strategy: type-guard
Validate before calling
const graphId = getSelectedGraphId();
if (!graphId || graphId.trim() === "") {
return; // skip API call until a graph id is known
} Type guard
const isValidId = (v) => typeof v === "string" && v.trim().length > 0;
Prevention
- Guard UI handlers so they no-op when no graph is selected
- Never send ids derived from possibly-empty state without checking
When it happens
Trigger: Sending a graph query with "id": "" or "id": " "; a missing id surfaces as 'Field [id] is required' from legacyField instead, so this message specifically means present-but-blank.
Common situations: Client code reading the graph id from a variable that was never populated; UI code passing an empty selection when no graph tab is active.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- database field name and type are required
- field name must not be empty
- Field [notebook] must not be empty
- Field [ ] must not be empty
- Field [type] must not be empty
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/04a6a95d93d3dcad.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/apicontract/graph_query.go:161
request.ReqID = reqID
defer func() {
if err != nil {
err = &graphQueryDecodeError{reqID, err}
}
}()
if len(fields["id"]) == 0 || bytes.Equal(bytes.TrimSpace(fields["id"]), []byte("null")) {
return request, nil
}
if request.K, err = legacyField[string](fields, "k", "String", false); err != nil {
return request, err
}
id, err := legacyField[string](fields, "id", "String", true)
if err != nil {
return request, err
}
id = strings.TrimSpace(id)
if id == "" {
return request, fmt.Errorf("Field [id] must not be empty")
}
request.ID = &id
configuration, err := decodeGraphConfiguration(fields)
if err != nil {
return request, err
}
request.Conf = configuration
if raw, exists := fields["notebook"]; exists {
_ = json.Unmarshal(raw, &request.Notebook)
}
return
}
GetGraph.decodeFailure = func(err error) Response[GlobalGraphData] {
var failure *graphQueryDecodeError
if errors.As(err, &failure) {
return GetGraph.FailureWithData(-1, err.Error(), GraphQueryEcho[GlobalGraphResult](failure.reqID))
}
return Failure[GlobalGraphData](-1, err.Error())View on GitHub (pinned to 9f775e8a12)