Skip to content

Fix two lockfile controller 500s - #239

Merged
JuanVqz merged 2 commits into
mainfrom
fix/lockfile-params-and-format
Sep 2, 2026
Merged

JuanVqz merged 2 commits into
mainfrom
fix/lockfile-params-and-format

Conversation

@JuanVqz

@JuanVqz JuanVqz commented Sep 2, 2026

Copy link
Copy Markdown
Member

Fixes two production 500s, one commit each.

undefined method 'fetch' for an instance of String (NoMethodError)
params.require(:lockfile) returns a String when a request sends lockfile as a bare scalar instead of lockfile[content]. The API now accepts both shapes and answers 422 invalid_content; the web controller uses params.expect, which raises ParameterMissing (400).

Missing template lockfiles/show_new … formats: [:json] (ActionView::MissingTemplate)
LockfilesController#show rendered :show_new for any format. JSON is served by API::LockfilesController on the api subdomain, so the web action responds to HTML only (406 otherwise).

A request for /lockfiles/:id.json reached the web controller, which
rendered :show_new unconditionally and raised
ActionView::MissingTemplate (500), since only show_new.html.erb exists.
The JSON representation is served by API::LockfilesController on the api
subdomain, so the web action now responds to HTML only. Other formats
raise ActionController::UnknownFormat, which Rails maps to 406 and
sentry-rails excludes from reporting by default.
API::LockfilesController#create called fetch on the result of
params.require(:lockfile), which returns a String when a request sends
lockfile as a bare scalar instead of the nested lockfile[content] hash,
raising NoMethodError (500). It now accepts both shapes and lets
Lockfile::Inspection answer with 422 invalid_content.

The web controller had the same crash through String#permit, reachable
by a hand-crafted POST though not by the form. It now uses
params.expect, which raises ParameterMissing (400) for unexpected
shapes.

ParameterMissing is in sentry-rails' default ignore list, so these
requests stop paging us.
@JuanVqz
JuanVqz marked this pull request as ready for review September 2, 2026 20:57
@JuanVqz
JuanVqz requested a review from etagwerker September 2, 2026 20:58
@JuanVqz JuanVqz self-assigned this Sep 2, 2026

@julioalucero julioalucero left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

@JuanVqz
JuanVqz merged commit f06a6cd into main Sep 2, 2026
2 checks passed
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