Skip to content

WI-005: #16 Missing problem constructors for common statuses (Unauthorized, Forbidden, Conflict, Unprocessable, Internal) - #23

Draft
rluders wants to merge 1 commit into
mainfrom
weave/wi-005-16-missing-problem-constructors-for-comm
Draft

rluders wants to merge 1 commit into
mainfrom
weave/wi-005-16-missing-problem-constructors-for-comm

Conversation

@rluders

@rluders rluders commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Work item WI-005 of work package WP-001 (GitHub issues).

problem_helpers.go ships ProblemBadRequest/NewBadRequestProblem and ProblemNotFound/NewNotFoundProblem, but nothing for the other statuses that come up just as often in a typical API:

  • 401 Unauthorized
  • 403 Forbidden
  • 409 Conflict
  • 422 Unprocessable Entity
  • 500 Internal Server Error

Without these, every call site falls back to the fully manual httpsuite.NewProblemDetails(status, type, title, detail) — which is exactly the 4-argument ceremony the NewBadRequestProblem/NewNotFoundProblem helpers exist to avoid for those two statuses.

Measured impact in one consumer (GolgiMed, ~150k LOC): 845 manual NewProblemDetails(...) calls, of which ~730 are exactly the canonical (status, "unauthorized", "Unauthorized", detail) / (status, "forbidden", "Forbidden", detail) / etc. shape that a NewUnauthorizedProblem(detail) / NewForbiddenProblem(detail) would collapse to one line.

Requested: ProblemUnauthorized/NewUnauthorizedProblem, ProblemForbidden/NewForbiddenProblem, ProblemConflict/NewConflictProblem, ProblemUnprocessable/NewUnprocessableProblem, ProblemInternal/NewInternalProblem, matching the existing ProblemBadRequest/ProblemNotFound pattern.

Implemented by the Weave Autoloop, attempt 1, execution exe_615c4b36a4f3.

Changed files:

  • problem_config.go
  • problem_helpers.go
  • problem_helpers_test.go

…rized, Forbidden, Conflict, Unprocessable, Internal)

Implemented by the Weave Autoloop, attempt 1 (execution exe_615c4b36a4f3).
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rluders

rluders commented Oct 12, 2026

Copy link
Copy Markdown
Owner Author

Weave review: approved (execution exe_f9b233c8304c)

The step report (generated/WF-002/exe_f9b233c8304c/step-1/report.json) shows go vet ./... and go test -count=1 ./... both exiting 0. I only read the files and the report. I did not run anything myself.

Criterion Implementation Test
ProblemUnauthorized / NewUnauthorizedProblem (401) problem_helpers.go:21-27, :71-74 problem_helpers_test.go:33, run through the table loop at :40-58
ProblemForbidden / NewForbiddenProblem (403) problem_helpers.go:29-35, :76-79 problem_helpers_test.go:34
ProblemConflict / NewConflictProblem (409) problem_helpers.go:37-43, :81-84 problem_helpers_test.go:35
ProblemUnprocessable / NewUnprocessableProblem (422) problem_helpers.go:45-51, :86-89 problem_helpers_test.go:36
ProblemInternal / NewInternalProblem (500) problem_helpers.go:53-59, :91-94 problem_helpers_test.go:37
Matches the existing ProblemBadRequest / ProblemNotFound pattern Same Problem(status).Type(GetProblemTypeURL(...)).Title(...).Detail(...) shape, and each New* calls .Build() Both the builder and direct variants are checked for every status
Type URLs resolve problem_config.go:21-24 adds unauthorized_error, forbidden_error, conflict_error and unprocessable_error. server_error already existed and is reused for 500. problem_helpers_test.go:54 compares against GetProblemTypeURL. Its want == BlankURL check fails the test if a key is missing, so an unregistered path can't pass silently.

Quality

  • Minimal: the change touches only the three listed files.
  • Documented: every new exported function has a doc comment in the style of the existing ones.
  • Test style: a table-driven test with t.Parallel(), which is idiomatic. It checks status, title, detail and type for both the builder and direct forms.

Non-blocking observations

  • Reusing `server_…
  • Person: approved — Operator review (Orkestra dogfood operator; NOT a GitHub review): five builder + five New* constructors follow the existing BadRequest/NotFound pattern; type paths registered in the default ProblemConfig; table-driven tests. CI observed by Orkestra after a Runtime restart during the wait (ci_passed at 53e269f). Ready for a human merge decision.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.78%. Comparing base (9b55b5e) to head (53e269f).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   83.60%   84.78%   +1.18%     
==========================================
  Files          14       14              
  Lines         500      539      +39     
==========================================
+ Hits          418      457      +39     
  Misses         63       63              
  Partials       19       19              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants