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
- Fix the JSON syntax of the custom field value named in the error (validate it with a JSON linter or `echo '<value>' | jq .`)
- If the value is meant to be a plain string, remove the leading '{' or '[' so it is not treated as JSON
- Quote the value properly when setting it via env vars or shell to avoid truncation
- 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
- Validate config JSON values with jq or json.Valid before loading the tracker
- Avoid hand-editing JSON values in config files; use a schema-validated config
- Keep plain string values free of leading '{' or '[' unless they are real JSON
- Add a config linter step in CI that exercises Init early
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
- parsing central config %s: %w
- parsing legacy config: %w
- parsing config: %w
- parsing %s: %w
- failed to load config: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/5a80baccbde103b2.
Report an issue: GitHub.