siyuan-note/siyuan · error

unsupported parsed attribute view field

Error message

unsupported parsed attribute view field %s

What it means

avDecodeParsedRequest only supports fields of kind String, Boolean, Number, and Slice. If a request struct declares a field of any other kind (object, map, nested struct), decoding aborts with 'unsupported parsed attribute view field <name>'. This is an internal contract mismatch: the struct schema and the parsed-request decoder are out of sync.

Solutions

  1. Change the request struct field to a supported kind (String, Boolean, Float64, or slice) or register a custom decodeRequest for the endpoint
  2. Update avDecodeParsedRequest to handle the new field kind if the schema genuinely needs it
  3. Report/fix the internal invariant violation if it occurs on an unmodified released kernel

Example fix

// before
type GetAttributeViewPasteRowsRequest struct {
    AvID string `json:"avID" api:"trim"`
    Extra map[string]string `json:"extra"` // unsupported kind
}
// after
type GetAttributeViewPasteRowsRequest struct {
    AvID string `json:"avID" api:"trim"`
    Extra string `json:"extra"` // or handle via a dedicated decoder
}
Defensive patterns

Strategy: type-guard

Validate before calling

// kernel-side: only String, Boolean, Float64, and slice fields may appear in structs decoded by avDecodeParsedRequest
const supportedKinds = new Set(["string","boolean","number"]);

Type guard

func isParsedAVFieldKind(f reflect.StructField) bool { switch f.Type.Kind() { case reflect.String, reflect.Bool, reflect.Float64, reflect.Slice: return true }; return false }

Try / catch

if err := decode(req); err != nil { if strings.Contains(err.Error(), "unsupported parsed attribute view field") { /* struct schema drifted; fix decoder or struct */ } return err }

Prevention

When it happens

Trigger: Adding/using an endpoint registered via avDecodeParsedRequest (getAttributeViewPasteRows, getAttributeViewFieldViews, createAttributeViewItem*) whose request struct contains a non-primitive, non-[]string field; typically seen after code changes or plugin-generated requests hitting a struct with unsupported fields.

Common situations: Kernel/plugin development where a new typed field (e.g. embedded object) was added to a parsed-request struct without updating the decoder, or building against mismatched kernel versions.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at kernel/apicontract/av_decode.go:168

			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 {
					decoded = append(decoded, item)
				}
			}
			value.Field(i).Set(reflect.ValueOf(decoded))
		default:
			return request, fmt.Errorf("unsupported parsed attribute view field %s", name)
		}
		if err != nil {
			return request, err
		}
	}
	return request, nil
}

View on GitHub (pinned to 9f775e8a12)