Skip to content

Fix discovery error handling#8

Open
nishantmodak wants to merge 2 commits intomainfrom
codex/find-and-fix-a-bug-in-the-codebase
Open

Fix discovery error handling#8
nishantmodak wants to merge 2 commits intomainfrom
codex/find-and-fix-a-bug-in-the-codebase

Conversation

@nishantmodak
Copy link
Copy Markdown
Member

Summary

  • return actual HTTP errors from Prometheus discovery API

Testing

  • npm run lint (fails: next not found)
  • npm install (fails: Exit handler never called)

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

The PR updates the Prometheus discovery endpoint to surface real HTTP errors instead of silently returning null, improving error transparency.

  • Replace return null with thrown status codes for HTTP and application-level failures.
  • Ensure actual HTTP response statuses are propagated on discovery errors.

Comment on lines +23 to +29
throw response.status;
}

const { data, status }: PrometheusQueryResponse = await response.json();

if (status !== "success") {
return null;
throw 500;
Copy link

Copilot AI May 18, 2025

Choose a reason for hiding this comment

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

[nitpick] Throwing a raw number makes it harder to include context or stack information; consider throwing an Error (e.g. throw new Error(Discovery failed: ${response.statusText})) or returning a NextResponse with the status code and message for clearer error handling.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@nishantmodak nishantmodak requested a review from sahilk May 18, 2025 18:14
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.

2 participants