Skip to content

feat(tb-bug): add error mutation commands (fix, ignore, discard, snooze)#27

Merged
d4be4st merged 3 commits into
mainfrom
tb-bug-error-actions
May 4, 2026
Merged

feat(tb-bug): add error mutation commands (fix, ignore, discard, snooze)#27
d4be4st merged 3 commits into
mainfrom
tb-bug-error-actions

Conversation

@d4be4st
Copy link
Copy Markdown
Contributor

@d4be4st d4be4st commented Apr 30, 2026

Summary

  • Adds tb-bug error fix|ignore|discard|snooze subcommands for mutating Bugsnag error state
  • New patch_errors API method handles both single and bulk error updates via Bugsnag's PATCH endpoint
  • discard requires --yes confirmation (or prompts interactively in a TTY) since it permanently drops future events
  • snooze accepts --for <duration> (e.g. 7d, 24h, 30m) or --events <n> for event-count-based snoozing
  • Cache is invalidated after any mutation

Test plan

  • tb-bug error fix --project <name> <error-id> — marks error as fixed
  • tb-bug error ignore --project <name> <error-id> — marks error as ignored
  • tb-bug error discard --project <name> <error-id> — prompts for confirmation; --yes skips prompt
  • tb-bug error snooze --project <name> --for 7d <error-id> — snoozes for 7 days
  • tb-bug error snooze --project <name> --events 10 <error-id> — snoozes until 10 more events

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@d4be4st d4be4st requested review from Copilot and trogulja April 30, 2026 08:08
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CLI support in tb-bug for mutating Bugsnag error state (fix/ignore/discard/snooze) and wires it to a new PATCH-based API helper that supports single and bulk updates, clearing cached error data after mutations.

Changes:

  • Introduces tb-bug error fix|ignore|discard|snooze subcommands (including discard --yes confirmation and snooze rules via duration or event-count).
  • Adds BugsnagClient::update_errors + internal patch_errors to call Bugsnag’s PATCH errors endpoint and invalidate cache after successful mutation.
  • Updates SKILL.md to document the new mutation capability.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/tb-bug/src/main.rs Adds error command routing and argument parsing for fix/ignore/discard/snooze.
crates/tb-bug/src/commands/mod.rs Exposes new error_action command module.
crates/tb-bug/src/commands/error_action.rs Implements mutation command handlers, duration parsing, and discard confirmation.
crates/tb-bug/src/api.rs Adds PATCH-based errors mutation API and cache invalidation on mutation.
crates/tb-bug/SKILL.md Documents new mutation commands in capabilities list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/tb-bug/src/api.rs
Comment on lines +514 to +518
if error_ids.len() == 1 {
body.insert("id".into(), serde_json::json!(error_ids[0]));
} else {
body.insert("error_ids".into(), serde_json::json!(error_ids));
}
Comment thread crates/tb-bug/src/api.rs Outdated
Comment on lines +513 to +523
body.insert("operation".into(), serde_json::json!(operation));
if error_ids.len() == 1 {
body.insert("id".into(), serde_json::json!(error_ids[0]));
} else {
body.insert("error_ids".into(), serde_json::json!(error_ids));
}
if let Some(serde_json::Value::Object(extra_map)) = extra {
for (k, v) in extra_map {
body.insert(k, v);
}
}
'd' | 'D' => 86_400,
other => return Err(format!("unknown duration unit '{other}' in {input}")),
};
Ok(n * mult)
format!("{}s", s)
}
}
SnoozeRule::Events(n) => format!("{} more events", n),
Comment thread crates/tb-bug/src/api.rs Outdated
}

/// PATCH a project's error(s). `body` is the raw JSON op payload.
/// Bugsnag accepts the same endpoint for single (`error_id`) and bulk (`error_ids`).
- Guard empty error_ids at API level (update_errors)
- Merge extra fields before reserved keys so callers can't override operation/id/error_ids
- Use checked_mul in parse_duration to prevent silent overflow
- Fix singular/plural for event-count snooze description
- Fix doc comment: single-error key is 'id', not 'error_id'

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@d4be4st d4be4st merged commit b97f848 into main May 4, 2026
1 check passed
@d4be4st d4be4st deleted the tb-bug-error-actions branch May 4, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants