Skip to content

HYPERFLEET-1247 - feat: introduce NTF-000 error code for endpoint not found#251

Open
rafabene wants to merge 1 commit into
openshift-hyperfleet:mainfrom
rafabene:HYPERFLEET-1247-introduce-ntf-000-error-code
Open

HYPERFLEET-1247 - feat: introduce NTF-000 error code for endpoint not found#251
rafabene wants to merge 1 commit into
openshift-hyperfleet:mainfrom
rafabene:HYPERFLEET-1247-introduce-ntf-000-error-code

Conversation

@rafabene

Copy link
Copy Markdown
Contributor

Summary

  • Adds CodeNotFoundEndpoint (HYPERFLEET-NTF-000) for the catch-all 404 handler (no route matched)
  • SendNotFound() now returns NTF-000 instead of NTF-001, allowing consumers to distinguish between a broken/misconfigured URL and a genuine resource not found (force-delete)
  • NTF-001 (CodeNotFoundGeneric) remains unchanged for service-layer resource-not-found responses

Test plan

Fixes: https://redhat.atlassian.net/browse/HYPERFLEET-1247

@openshift-ci openshift-ci Bot requested review from crizzo71 and mbrudnoy June 24, 2026 21:31
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ma-hill for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e9c1bec9-a7d4-40fd-8355-898da5bbfb67

📥 Commits

Reviewing files that changed from the base of the PR and between f5a4809 and 8e6c795.

📒 Files selected for processing (4)
  • pkg/api/error.go
  • pkg/api/error_test.go
  • pkg/errors/errors.go
  • pkg/errors/errors_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)
✅ Files skipped from review due to trivial changes (1)
  • pkg/api/error_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/api/error.go
  • pkg/errors/errors.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Updated “Not Found” (404) responses to use a more specific standardized problem details code for missing endpoints.
  • New Features
    • Added a new RFC 9457 error code for “Endpoint Not Found” to improve consistency of error metadata.
  • Tests
    • Added/extended API and error-code tests to verify the new 404 problem details payload and code resolution behavior.

Walkthrough

Adds CodeNotFoundEndpoint (HYPERFLEET-NTF-000) to the RFC 9457 error catalog and maps it to a 404 Not Found problem definition. SendNotFound now returns that code instead of CodeNotFoundGeneric.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: introducing NTF-000 for endpoint-not-found responses.
Description check ✅ Passed The description matches the changeset and explains the new 404 code split and test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sec-02: Secrets In Log Output ✅ Passed PASS: Reviewed non-test Go log/print sites; none log token/password/credential/secret fields or interpolated values. No CWE-532 exposure found.
No Hardcoded Secrets ✅ Passed No hardcoded credentials, tokens, passwords, private keys, embedded creds, or long base64 literals found in the changed Go files (CWE-798).
No Weak Cryptography ✅ Passed No CWE-327/CWE-208 issues: the PR diff has no md5/des/rc4/SHA1-for-security/ECB or secret-compare misuse; only rsa/rand imports appear.
No Injection Vectors ✅ Passed No CWE-89/CWE-78/CWE-79/CWE-502 patterns were added; the PR only changes 404 error codes and tests, with no dangerous query/exec/template/yaml use.
No Privileged Containers ✅ Passed PR only touches Go files; no new privileged flags in manifests/templates/Dockerfiles. Existing Dockerfile USER root is pre-existing and justified.
No Pii Or Sensitive Data In Logs ✅ Passed No new logging/print callsites were added in the touched files; existing logs are static and do not emit PII, bodies, or credentials. No CWE-532 regression.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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

@hyperfleet-ci-bot

hyperfleet-ci-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

Risk Score: 0 — risk/low

Signal Detail Points
PR size 41 lines +0
Sensitive paths none +0
Test coverage Tests cover changed packages +0

Computed by hyperfleet-risk-scorer

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/api/error.go (1)

22-30: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Align 404 text fields with CodeNotFoundEndpoint semantics (CWE-436).

Code now indicates endpoint-not-found, but Title/Detail still describe resource-not-found. Keep these fields consistent so clients and operators don’t misclassify route misses.

Suggested patch
-	detail := fmt.Sprintf("The requested resource '%s' doesn't exist", r.URL.Path)
+	detail := fmt.Sprintf("The requested endpoint '%s' does not exist", r.URL.Path)
...
-		Title:     "Resource Not Found",
+		Title:     "Endpoint Not Found",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/api/error.go` around lines 22 - 30, The 404 ProblemDetails in error
handling are inconsistent with CodeNotFoundEndpoint semantics because the Title
and Detail still describe a generic resource miss. Update the response
construction in the error response path that builds openapi.ProblemDetails so
the Title and Detail consistently describe an endpoint/route not found, matching
the CodeNotFoundEndpoint value and the existing errors.ErrorTypeNotFound. Keep
the same identifiers and structure, just align the text fields with the
endpoint-not-found meaning.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/errors/errors.go`:
- Around line 43-44: The route-level 404 contract is using the wrong shared code
in docs and tests, while `CodeNotFoundEndpoint` should be the published value
for endpoint 404s and `CodeNotFoundGeneric` should remain for resource lookup
failures. Update every place that publishes or asserts the route-level 404
response to use `CodeNotFoundEndpoint` consistently, and leave
`CodeNotFoundGeneric` unchanged for generic/not-found resource cases; use the
`pkg/errors` constants as the source of truth when fixing downstream fixtures
and documentation.

---

Outside diff comments:
In `@pkg/api/error.go`:
- Around line 22-30: The 404 ProblemDetails in error handling are inconsistent
with CodeNotFoundEndpoint semantics because the Title and Detail still describe
a generic resource miss. Update the response construction in the error response
path that builds openapi.ProblemDetails so the Title and Detail consistently
describe an endpoint/route not found, matching the CodeNotFoundEndpoint value
and the existing errors.ErrorTypeNotFound. Keep the same identifiers and
structure, just align the text fields with the endpoint-not-found meaning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c06c4e39-beaa-40d9-800b-c418a45f5bc3

📥 Commits

Reviewing files that changed from the base of the PR and between 47284f3 and f5a4809.

📒 Files selected for processing (2)
  • pkg/api/error.go
  • pkg/errors/errors.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift-hyperfleet/architecture (manual)
  • openshift-hyperfleet/hyperfleet-api (manual)
  • openshift-hyperfleet/hyperfleet-sentinel (manual)
  • openshift-hyperfleet/hyperfleet-adapter (manual)
  • openshift-hyperfleet/hyperfleet-broker (manual)

Comment thread pkg/errors/errors.go
… found

The catch-all 404 handler now returns HYPERFLEET-NTF-000 instead of
NTF-001, allowing consumers to distinguish between a broken/misconfigured
URL (no route matched) and a genuine resource not found (force-delete).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant