Skip to content

Fix madmin - #142

Merged
JuanVqz merged 2 commits into
mainfrom
maintenance/madmin-ostruct
Jul 30, 2026
Merged

Fix madmin#142
JuanVqz merged 2 commits into
mainfrom
maintenance/madmin-ostruct

Conversation

@JuanVqz

@JuanVqz JuanVqz commented Jul 30, 2026

Copy link
Copy Markdown
Member

Description:

Fixing Ostruct

I will abide by the code of conduct.

JuanVqz added 2 commits July 30, 2026 10:26
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.
@JuanVqz JuanVqz changed the title Maintenance/madmin ostruct Fix madmin Jul 30, 2026
@JuanVqz
JuanVqz marked this pull request as ready for review July 30, 2026 16:45
@JuanVqz
JuanVqz merged commit 7f6c45a into main Jul 30, 2026
3 checks passed
@JuanVqz
JuanVqz deleted the maintenance/madmin-ostruct branch July 30, 2026 16:45
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.

1 participant