feat(cases): fix create flag path, add comment subcommands, split case-management agent#504
Merged
Merged
Conversation
…number default Four related case-management CLI fixes surfaced while using pup against real cases: - `cases create --type-id <id>` was sending a malformed JSON body. The type_id was being stuffed into `data.attributes.type` rather than `data.attributes.type_id`, and the project relationship couldn't be attached at all. Replace the hand-rolled JSON with the typed `CaseCreateRequest` from the API client so the shape matches the spec. - Add `--project-id <uuid>` to `cases create`. Builds `CaseCreateRelationships` from the flag value. Closes the gap where the only way to assign a new case to a project was the `--file` path. Cases without a project assignment are hard to find later (most search facets require `project_id`). - Add `cases comment <case-id> --body "..."` subcommand wrapping the `comment_case` API method. Previously there was no CLI surface for posting comments; users had to construct raw `pup api -X POST v2/cases/<id>/comment` calls with the right JSON:API shape, which required iteration to discover (the comment body needs `"type": "case"`, not the intuitive `"case_comment"`). - Add `cases delete-comment <case-id> --comment-id <id>` wrapping `delete_case_comment`. - `cases search --page-number` defaulted to 0, but the API rejects 0 with `page number must be > 0`. Change the default to 1. - Extract a shared `parse_priority` helper used by both `create_from_flags` and `update_priority` (previously duplicated). Tests cover happy paths for both new subcommands, the new `--project-id` path on create, the previously-broken-now-fixed flag create path, and the priority parser (valid + invalid). All 12 case tests pass; cargo fmt + clippy clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Datadog Case Management is a standalone product used by Incident Response, Error Tracking, Security Signals, and ad-hoc operator workflows. The incident-response agent bundled the entire case CLI surface inside it, which made it hard for non-incident consumers to find and meant case documentation only updated when someone touched incident-response. Extract `agents/case-management.md` as its own agent covering the full `pup cases ...` surface. Slim `agents/incident-response.md` to reference case-management for case operations, retaining only the short incident-flow examples that chain into case actions. Update the case-management mention in `agents/error-tracking.md` to point at the new agent. While doing the extraction, fix several inaccurate CLI examples in incident-response that didn't match the actual pup CLI: - `pup cases list` -> `pup cases search` (with --query) - `pup cases update CASE --status=X` -> `pup cases update-status CASE --status X` - `pup cases comment --text=` -> `pup cases comment --body` - `pup cases assign --user=<email>` -> `pup cases assign --user-id <uuid>` - `pup cases unassign` -> removed (no such subcommand) - `pup cases attribute` -> removed (no such subcommand) - `pup cases projects create --name=` -> requires both --name and --key The new case-management agent documents the correct CLI surface, the known API gaps (no list-comments endpoint, comment_count doesn't refresh promptly), and the well-supported search facet (`project_id:<uuid>`). incident-response.md shrinks from 834 to 714 lines; case-management.md is 288 lines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Confirmed via dev-binary smoke test: searches for substrings that exist only in comments return zero results (toolbox-shell comment phrases, PR numbers posted as comments, etc.), while the same kind of substring from a case title or description matches. Combined with the missing list-comments endpoint, this means there's no way to find a case by its comments via the CLI — operators must use the Datadog UI for any comment-based discovery. Also corrects the `comment_count` note: it's not a refresh-lag issue — the field is always 0 on `pup cases get`, and is only populated in `pup cases search` results. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ff5feae to
db8e40c
Compare
The `update_case_description` API method exists in the client but
wasn't exposed by the CLI. Add `pup cases update-description <case-id>
--description "..."` matching the existing update-{status,priority,title}
pattern.
This is more than just symmetry. Combined with the gaps already
documented in the new case-management agent (no list-comments endpoint,
search not indexing comment text, comment_count always 0 on get), the
description is the only case-level surface that's both updatable and
discoverable via CLI. The new agent now recommends synthesizing
rollup-style status in the description rather than scattered comments
when CLI discoverability matters.
Test coverage parallels the existing update-* tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
platinummonkey
approved these changes
May 14, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related changes bundled under "improve case management":
CLI fixes for
pup cases:cases createflag path was sending malformed JSON (type_idstuffed intodata.attributes.typeinstead ofdata.attributes.type_id, no way to attach a project relationship). Replaced the hand-rolled JSON with the typedCaseCreateRequestfrom the API client.--project-id <uuid>flag tocases createso the flag path can assign a project on create (previously only--filecould).cases comment <case-id> --body "..."andcases delete-comment <case-id> --comment-id <id>subcommands wrappingcomment_case/delete_case_comment. Previously the only path to commenting was rawpup api -X POST v2/cases/<id>/commentwith hand-built JSON.cases update-description <case-id> --description "..."subcommand wrappingupdate_case_description. The API method existed but wasn't exposed. Combined with the comment-API gaps, the description is the only case-level surface that's both updatable and discoverable via CLI, so this unlocks the "synthesize rollup status in the description" workflow.cases search --page-numberdefault from0to1. The API rejects 0 withpage number must be > 0, so the documented default never produced a successful call.parse_priorityhelper (was duplicated betweencreate_from_flagsandupdate_priority).Agent docs refactor — extract case-management from incident-response:
agents/case-management.mdcovering the fullpup cases ...surface. Case Management is a standalone Datadog product used by Incident Response, Error Tracking, Security Signals, and ad-hoc operator workflows — burying it insideincident-responsemade it harder for non-incident consumers to find.agents/incident-response.md(834 → 714 lines) to reference case-management for case ops, keeping only the short incident-flow snippets that chain into case actions.agents/error-tracking.mdto point at the new agent for its case mention.pupCLI (e.g.,pup cases list→pup cases search;pup cases update CASE --status=X→pup cases update-status CASE --status X;--user=<email>→--user-id <uuid>; etc.).Why these came up together
These fixes surfaced while using
pup casesend-to-end against real cases — opening cases, leaving PR-link comments, synthesizing rollup status, etc. The CLI gaps (no--project-id, malformed create body, no comment subcommand, no description-update subcommand,--page-number 0rejected) forced repeated raw-API workarounds, and the agent docs documented behavior that didn't match the actual CLI. Single PR keeps the "improve case management" thread coherent rather than splitting closely-related fixes.Changes
CLI (
src/)src/commands/cases.rs— rewrotecreate_from_flagsto use typedCaseCreateRequest+ addproject_id: Option<&str>parametersrc/commands/cases.rs— newcomment,delete_comment, andupdate_descriptionfunctionssrc/commands/cases.rs— extractedparse_priorityhelper;update_prioritynow uses itsrc/main.rs—cases search --page-numberdefault → 1src/main.rs— newproject_idflag on theCreateclap structsrc/main.rs— newComment,DeleteComment, andUpdateDescriptionclap variants + routingTests
src/commands/cases.rs:tests— added tests forcreate_from_flags(happy path + with--project-id+ invalid priority),comment,delete_comment,update_description,parse_priority(valid + invalid). All 13 case tests pass.Docs (
agents/)agents/case-management.md— new, ~290 lines, full case CLI surface + known API gaps (no list-comments endpoint, comment text not search-indexed,comment_countalways 0 ongetand only populated bysearch). Recommends synthesizing rollup-style status in the description rather than comments when CLI discoverability matters.agents/incident-response.md— slimmed to 714 lines, references case-management for case ops, fixed inaccurate CLI snippets in remaining workflow sections.agents/error-tracking.md— pointer to case-management for its case mention.Test plan
cargo build— cleancargo test --bin pup cases::— 13 tests passcargo fmt --check— cleancargo clippy -- -D warnings— cleanpup cases get <human-key>— works with the human keypup cases search --query "project_id:<uuid>"— no--page-numberneeded (default 1)pup cases comment <case-id> --body "..."— posts; response includes the new comment idpup cases delete-comment <case-id> --comment-id <id>— deletes; second-delete returns 404 confirming the first took effectKnown API gaps (not addressed in this PR — upstream Case Management API team)
case-managementagent.comment_countis always0on theget_caseresponse — only populated bysearch_casesresults.search_casesdoes not index comment text (title and description only).The new agent documents these so users know to fall back to the UI for comment-based discovery.