Repository navigation
Conversation
The dashboard is HTML only, so a script or an agent that watches production errors had to scrape it or query the database. The API has the dashboard's four actions with its rules, behind a single api_key sent as a bearer token. It is off, answering 404, until the key is set, and it inherits from ActionController::API rather than base_controller_class, so a dashboard behind a session sign-in or basic auth does not lock it out.
A PATCH with resolved_at let any JSON value into the column: a number or
true was stored as is, and an unparseable string reopened the error.
The API now takes {"error": {"resolved": true}} or false and sets the
time itself; anything else, including a missing or non-object error
key, gets a 422.
Failures answer in JSON: the routes default to it, and a wrong key gets
a JSON 401. Occurrence backtraces are filtered to [PROJECT_ROOT] and
[GEM_ROOT] as on the dashboard. Page clamps items and page to at least
one, so items=0 no longer raises and page=0 no longer gives a negative
offset, and exposes the current page. An empty api_key falls back to
SOLIDERRORS_API_KEY. The README says the API can't be reached behind a
session constraint such as Devise's authenticate.
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.
The dashboard is HTML only, so a script or an AI agent that watches production errors has to scrape it or reach into the errors database. This adds the dashboard's four actions as JSON, behind a single key.
config.solid_errors.api_key(orSOLIDERRORS_API_KEY) is set; until then the API answers 404.Authorization: Bearer <key>), compared withsecure_compare. The controller inherits fromActionController::API, notbase_controller_class, and ignoresusernameandpassword, so a dashboard behind basic auth or a custom base controller doesn't lock the API out. Route constraints around the mount still apply, so behind a session constraint such as Devise'sauthenticatethe API can't be reached with a key alone; the README says so and how to mount around it.GET /api/errors: the unresolved errors (or?scope=resolved), latest occurrence first, withoccurrences_count,first_seen_atandlast_seen_atGET /api/errors/:id: the error with itsmarkdown(fromto_markdown) and a page of its occurrences with filtered backtraces, using the dashboard'spageanditemsPATCH /api/errors/:id:{"error": {"resolved": true}}resolves it now,falsereopens it, anything else gets 422DELETE /api/errors/:id: a resolved error only; an unresolved one gets 422 with the dashboard's messageThe API exposes the dashboard's
Pageto scripts, soPagenow treatsitemsandpagebelow one as one (items=0raisedFloatDomainError,page=0gave a negative offset) and exposes the current page. The 422 is a number because Rack 3.1 deprecates:unprocessable_entityand older Racks don't know:unprocessable_content.Tests cover each action, bad PATCH bodies, page and items below one, filtered backtraces, a wrong or missing key, the API being off without a key, and an empty
api_keyfalling back to the environment variable. The suite passes on Rails 7.1 and 8.1 andstandardis clean. The README documents it under Configuration → JSON API.We run Solid Errors in production and have an agent check it every half hour; this is what it needed.