multica-ai/multica · error

value must be true or false

Error message

value must be true or false

What it means

validatePropertyValue requires checkbox-type property values to be JSON true or false. Any other JSON type — string "true", number 1/0, null in a value position (null at the top of validatePropertyValue gives a different 'cannot be null' error) — is rejected. The value is stored verbatim after the check.

Source

Thrown at server/internal/handler/property.go:350

			return nil, errors.New("value must be a URL string")
		}
		s = strings.TrimSpace(s)
		if len(s) > maxPropertyURLValueLen {
			return nil, fmt.Errorf("value must be %d characters or fewer", maxPropertyURLValueLen)
		}
		u, err := url.Parse(s)
		if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
			return nil, errors.New("value must be an http(s) URL")
		}
		return json.Marshal(s)
	case "number":
		if _, ok := v.(float64); !ok {
			return nil, errors.New("value must be a number")
		}
		return json.Marshal(v)
	case "checkbox":
		if _, ok := v.(bool); !ok {
			return nil, errors.New("value must be true or false")
		}
		return json.Marshal(v)
	case "date":
		s, ok := v.(string)
		if !ok {
			return nil, errors.New("value must be a date string in YYYY-MM-DD format")
		}
		if _, err := time.Parse("2006-01-02", s); err != nil {
			return nil, errors.New("value must be a date string in YYYY-MM-DD format")
		}
		return json.Marshal(s)
	case "select":
		s, ok := v.(string)
		if !ok {
			return nil, fmt.Errorf("value must be one of the option ids: %s", selectOptionsHint(cfg))
		}
		if _, exists := propertyOptionIDs(cfg)[s]; !exists {
			return nil, fmt.Errorf("value must be one of the option ids: %s", selectOptionsHint(cfg))

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Send a real JSON boolean: {"value": true}
  2. Convert form state with Boolean(x) or x === "on" before the request
  3. To unset a checkbox, send null or use DELETE rather than false-if-you-mean-unset

Example fix

// before
{ value: 1 }
// after
{ value: true }
Defensive patterns

Strategy: type-guard

Validate before calling

if (def.type === 'checkbox') {
  if (typeof value !== 'boolean') throw new Error('Property expects true/false');
  payload.value = value;
}

Type guard

function isCheckboxPropertyValue(v: unknown): v is boolean {
  return typeof v === 'boolean';
}

Prevention

When it happens

Trigger: PUT/PATCH a checkbox property with {"value": "true"}, {"value": 1}, or {"value": 0}. Happens with checkbox inputs serialized by form libraries that emit "on"/"off" or 0/1 instead of booleans.

Common situations: HTML checkbox forms yielding "on" strings; SQLite/legacy columns storing 0/1 re-exported into the API; Python clients truthy-coercing values before JSON encoding.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/e8ff2b787b5d3cc8. Report an issue: GitHub.