Skip to content

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

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift-hyperfleet:mainfrom
rafabene:HYPERFLEET-1247-introduce-ntf-000-error-code
Jun 25, 2026
Merged

HYPERFLEET-1247 - feat: introduce NTF-000 error code for endpoint not found#251
openshift-merge-bot[bot] merged 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

@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: 389b210c-af58-405b-96a7-88e02cfc315a

📥 Commits

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

📒 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) → reviewed against open PR #211 HYPERFLEET-1247-distinguish-precondition-404-from-force-delete instead of the default branch
  • openshift-hyperfleet/hyperfleet-broker (manual)
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/api/error_test.go
  • pkg/errors/errors_test.go
  • pkg/api/error.go
  • pkg/errors/errors.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Updated 404 “Not Found” responses to use a more specific RFC 9457 problem-details code and updated the “title”/“detail” text to refer to missing endpoints.
  • New Features
    • Added a new RFC 9457 error code for “Endpoint Not Found” to improve consistency of 404 error metadata.
  • Tests
    • Added/extended tests to verify the 404 problem+json payload (status/title/code/detail) and that the new code resolves correctly.

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 | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: introducing NTF-000 for endpoint-not-found 404 handling.
Description check ✅ Passed The description is aligned with the changeset and correctly explains the new endpoint-not-found code and behavior.
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: No non-test/example log statements in the PR interpolate or field-map token/password/credential/secret; only error-code mapping changed. CWE-532 not present.
No Hardcoded Secrets ✅ Passed No hardcoded secrets, embedded credentials, or long base64 literals found in the touched files; only non-sensitive error-code strings. CWE-798 not present.
No Weak Cryptography ✅ Passed No crypto/md5, crypto/des, crypto/rc4, SHA1/ECB, or secret comparisons found in touched files; only RFC9457 error-code/test edits (CWE-327).
No Injection Vectors ✅ Passed No CWE-89/78/79/502 sinks were added in touched code; changes only add error-code constants and JSON problem-details fields.
No Privileged Containers ✅ Passed No privileged settings in deployed manifests/templates; the only USER root is a documented build-stage exception before switching back to non-root (CWE-250 not exposed).
No Pii Or Sensitive Data In Logs ✅ Passed PASS: The PR only changes 404 error codes/messages; no new slog/logr/zap/printf logging was added, and touched logs don't emit bodies, tokens, or obvious PII (CWE-532).

✏️ 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 46 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).
@rafabene rafabene force-pushed the HYPERFLEET-1247-introduce-ntf-000-error-code branch from 8e6c795 to f296507 Compare June 25, 2026 12:50
@kuudori

kuudori commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kuudori

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

The pull request process is described 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

@openshift-merge-bot openshift-merge-bot Bot merged commit 177f746 into openshift-hyperfleet:main Jun 25, 2026
9 checks passed
openshift-merge-bot Bot added a commit to openshift-hyperfleet/hyperfleet-adapter that referenced this pull request Jun 25, 2026
…211)

## Summary

- Adapter now checks the RFC 9457 error code on 404 responses to
distinguish broken endpoints from force-deleted resources
- A 404 with code `HYPERFLEET-NTF-000` (catch-all, no route matched) is
treated as a configuration error
- Any other 404 (including missing/stripped response body) defaults to
resource-not-found — graceful handling
- Added `IsResourceNotFound()` / `IsResourceNotFoundError()` to
`pkg/errors/api_error.go`
- Updated test fixtures to use RFC 9457 format
- Updated adapter-authoring-guide documentation

## Dependencies

- Requires API PR:
openshift-hyperfleet/hyperfleet-api#251

## Test plan

- [x] Unit tests for `IsResourceNotFound` with
NTF-000/NTF-002/NTF-003/empty body/unparseable body
- [x] Unit tests for `IsResourceNotFoundError` with direct and wrapped
errors
- [x] Executor test: broken URL 404 (NTF-000) results in error status
- [x] Executor test: resource not found 404 (NTF-002) continues graceful
handling
- [x] All existing 404 tests still pass
- [x] `make lint` passes with 0 issues

Fixes: https://redhat.atlassian.net/browse/HYPERFLEET-1247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants