gastownhall/beads · error

parse %s: %w

Error message

parse %s: %w

What it means

Init parses custom Jira field values from the tracker configuration. When a configured custom field value looks like a JSON object or array (starts with '{' or '['), it is passed through parseJiraCustomFieldValue, which json.Unmarshal's it. If the JSON is malformed, Init wraps the parse error with the offending field key so the user knows exactly which field entry is invalid.

Source

Thrown at internal/jira/tracker.go:146

			t.priorityMap = priorityMap
		}

		const customFieldPrefix = "jira.custom_fields."
		customFields := make(map[string]interface{})
		typeCustomFields := make(map[string]map[string]interface{})
		for key, val := range allConfig {
			if !strings.HasPrefix(key, customFieldPrefix) || strings.TrimSpace(val) == "" {
				continue
			}

			suffix := strings.TrimPrefix(key, customFieldPrefix)
			if suffix == "" {
				continue
			}

			parsed, err := parseJiraCustomFieldValue(val)
			if err != nil {
				return fmt.Errorf("parse %s: %w", key, err)
			}

			parts := strings.SplitN(suffix, ".", 2)
			if len(parts) == 2 {
				if parts[0] == "" || parts[1] == "" {
					continue
				}
				if typeCustomFields[parts[0]] == nil {
					typeCustomFields[parts[0]] = make(map[string]interface{})
				}
				typeCustomFields[parts[0]][parts[1]] = parsed
				continue
			}
			customFields[suffix] = parsed
		}
		if len(customFields) > 0 {
			t.customFields = customFields
		}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Fix the JSON syntax of the custom field value named in the error (validate it with a JSON linter or `echo '<value>' | jq .`)
  2. If the value is meant to be a plain string, remove the leading '{' or '[' so it is not treated as JSON
  3. Quote the value properly when setting it via env vars or shell to avoid truncation
  4. Use the error-wrapped key (%s) to locate the exact config entry to fix

Example fix

// before
[config.toml]
customfield_10012 = '{"name": "Bug"'  // missing closing brace
// after
customfield_10012 = '{"name": "Bug"}'
Defensive patterns

Strategy: validation

Validate before calling

for key, val := range cfg.CustomFields {
	t := strings.TrimSpace(val)
	if (strings.HasPrefix(t, "{") || strings.HasPrefix(t, "[")) && json.Valid([]byte(t)) == false {
		return fmt.Errorf("custom field %q is not valid JSON: %q", key, val)
	}
}

Prevention

When it happens

Trigger: Calling jira Tracker.Init with a config where a custom field (key with a recognized custom-field suffix) has a value like '{invalid' or '[1,2' — trimmed non-empty, starts with '{' or '[', but fails json.Unmarshal.

Common situations: Hand-edited config files where braces/quotes were dropped; shell/CI templating that mangled JSON; pasting a field value with trailing commas or single quotes; environment variables holding truncated JSON.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/5a80baccbde103b2. Report an issue: GitHub.