Fix madmin - #142
Merged
Merged
Conversation
Every madmin screen 500s in production with "Madmin couldn't find attribute or association 'name' on AnalyzedFile model", listing 'name' among the attributes it searched. The contradiction is the clue: madmin's `attribute` has a bare `rescue => e` (madmin-1.2.5/lib/madmin/resource.rb:39) that turns any exception into that message. The real error is a NameError on OpenStruct, which line 37 uses without requiring "ostruct". Nothing required it in production. json 2.6 pulls ostruct in through json/generic_object, which is why development and CI were fine; the dyno runs json 2.7, which dropped that require. Confirmed on the dyno: defined?(OpenStruct) is nil there. So ostruct becomes an explicit dependency, and json moves to 2.21.1 in both lockfiles so tests run against the same json as production. That second half is what makes the existing madmin smoke tests a real guard: with json aligned and the gem removed, four of them error. ostruct also leaves the default gems in Ruby 3.5, so this was coming regardless.
The admin was 500ing in production while these tests passed. The tests were not the problem, the bundle was: they only ran against a json that required ostruct for us. But they also only asserted status codes, so they had no way to notice a resource that resolved and rendered nothing. - The dashboard test asserts the per-resource navigation links exist, which is what forces attribute resolution. - The screen tests assert a heading renders, and a new test asserts the record's own attributes reach the index and show pages. - A new test resolves every registered resource's attributes directly. madmin reports any failure there as a missing attribute, so naming the step gives that error somewhere honest to land, and covers resources added later without a screen test. With the ostruct dependency removed, six of the eight now error instead of passing.
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.
Description:
Fixing Ostruct
I will abide by the code of conduct.