gastownhall/beads · error
marshaling Linear milestone metadata: %w
Error message
marshaling Linear milestone metadata: %w
What it means
After merging the existing metadata with the Linear milestone fields (title, targetDate, etc.), the function re-serializes the map with json.Marshal. Marshaling a map[string]interface{} built from valid values essentially never fails in Go unless a value contains an unsupported type (e.g. a channel or func snuck in via the parsed existing data), but the error is wrapped defensively.
Source
Thrown at cmd/bd/linear.go:706
}
linearMeta, _ := data["linear"].(map[string]interface{})
if linearMeta == nil {
linearMeta = make(map[string]interface{})
}
linearMeta["kind"] = "project_milestone"
linearMeta["project_milestone"] = map[string]interface{}{
"id": strings.TrimSpace(ms.ID),
"name": ms.Name,
"description": ms.Description,
"progress": ms.Progress,
"targetDate": ms.TargetDate,
}
data["linear"] = linearMeta
raw, err := json.Marshal(data)
if err != nil {
return nil, fmt.Errorf("marshaling Linear milestone metadata: %w", err)
}
return json.RawMessage(raw), nil
}
func issueHasLinearMilestoneID(issue *types.Issue, milestoneID string) bool {
if issue == nil || len(issue.Metadata) == 0 {
return false
}
var data struct {
Linear struct {
Kind string `json:"kind"`
ProjectMilestone struct {
ID string `json:"id"`
} `json:"project_milestone"`
} `json:"linear"`
}
if err := json.Unmarshal(issue.Metadata, &data); err != nil {
return falseView on GitHub (pinned to 71377f2769)
Solutions
- Inspect the issue's metadata for unsupported/garbage values and reset it to a plain JSON object
- Retry the sync; if persistent, report the metadata content that triggers it as a bug
- Update bd to the latest version in case the merge logic changed
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := json.Marshal(data); err != nil {
// abort before calling the sync API
} Try / catch
raw, err := mergedLinearMilestoneMetadata(existing, ms)
if err != nil {
return fmt.Errorf("merge milestone metadata failed: %w", err)
} Prevention
- Keep metadata values to JSON-encodable primitives and maps
- Avoid injecting Go values with channels/funcs into metadata maps
- Report persistent marshal failures with the offending metadata to maintainers
When it happens
Trigger: json.Marshal fails on the merged metadata map — practically only when existing parsed metadata contained values of unsupported types that survive into the output map.
Common situations: Extremely rare; typically indicates corrupted or programmatically injected metadata with non-JSON-encodable values. Most users will never see this.
Related errors
- existing milestone metadata is not a JSON object: %w
- failed to marshal request: %w
- failed to marshal metadata: %w
- failed to marshal merged metadata: %w
- failed to marshal metadata: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/dfb699959d9c7c4a.
Report an issue: GitHub.