siyuan-note/siyuan · error
Field [ ] must not be empty
Error message
Field [%s] must not be empty
What it means
avDecodeParsedRequest walks request struct fields reflectively; for string-kind fields tagged with the ,trim, api option, the decoded value is trimmed and an all-whitespace/empty value fails with 'Field [<name>] must not be empty'. Used by endpoints like getAttributeViewPasteRows and createAttributeViewItem variants.
Solutions
- Provide a non-empty, trimmed value for the flagged field
- Validate inputs client-side (trim + length check) before invoking the endpoint
- If the field should be optional, verify you are calling the right endpoint for your use case
Example fix
// before
fetchPost("/api/av/getAttributeViewPasteRows", {avID: " ", srcIDs});
// after
const id = avID.trim();
if (!id) throw new Error("avID is required");
fetchPost("/api/av/getAttributeViewPasteRows", {avID: id, srcIDs}); Defensive patterns
Strategy: validation
Validate before calling
function assertTrimmed(payload, names) { for (const n of names) { const v = payload[n]; if (typeof v !== "string" || !v.trim()) throw new Error(`Field [${n}] must not be empty`); } } Type guard
const isTrimmedNonEmpty = (v) => typeof v === "string" && v.trim() !== "";
Try / catch
try { await post(avEndpoint, payload); } catch (e) { if (/must not be empty/.test(e.message)) { /* surface which field: e.message */ } else throw e; } Prevention
- Trim ID strings at the source (UI selection, clipboard) before storing them
- Guard against empty selections before issuing paste/field-view calls
- Keep a helper that validates av endpoints' required trimmed fields
When it happens
Trigger: Calling /api/av/getAttributeViewPasteRows, getAttributeViewFieldViews, or createAttributeViewItem* with a required,trim string field (e.g. avID, srcIDs values) set to "", " ", or missing while required.
Common situations: Row/column IDs extracted from UI state that came back empty, copy/paste flows where the source selection was empty, API scripts hardcoding blank strings during testing.
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
- Field [ ] must not be empty
- AI editor action must not be empty
- AI editor input is empty
- asset data is empty
- at least one asset path or mapping is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/f4a2887c7f48583a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/apicontract/av_decode.go:144
func avDecodeParsedRequest[Request any](reader io.Reader, path string) (request Request, err error) {
fields, err := blockRequestFields(reader, path)
if err != nil {
return request, err
}
value := reflect.ValueOf(&request).Elem()
for i := 0; i < value.NumField(); i++ {
field := value.Type().Field(i)
name := field.Tag.Get("json")
options := "," + field.Tag.Get("api") + ","
required := !strings.Contains(options, ",optional,")
switch field.Type.Kind() {
case reflect.String:
var decoded string
decoded, err = legacyField[string](fields, name, "String", required)
if err == nil && strings.Contains(options, ",trim,") {
decoded = strings.TrimSpace(decoded)
if decoded == "" {
err = fmt.Errorf("Field [%s] must not be empty", name)
}
}
value.Field(i).SetString(decoded)
case reflect.Bool:
var decoded bool
decoded, err = legacyField[bool](fields, name, "Boolean", required)
value.Field(i).SetBool(decoded)
case reflect.Float64:
var decoded float64
decoded, err = legacyField[float64](fields, name, "Number", required)
value.Field(i).SetFloat(decoded)
case reflect.Slice:
var entries []json.RawMessage
entries, err = legacyField[[]json.RawMessage](fields, name, "Array", required)
var decoded []string
for _, entry := range entries {
var item string
if !bytes.Equal(entry, []byte("null")) && json.Unmarshal(entry, &item) == nil {View on GitHub (pinned to 9f775e8a12)