Repository navigation
fix(datasource_active_record): skip anonymous models when building collections - #413
Conversation
…llections The audit trail binds its table through an anonymous ActiveRecord class, and the datasource called `name.start_with?` on every ActiveRecord::Base descendant, so a Rails app with the audit trail on crashed at boot on `nil`. A nameless model can't name a collection, so it is skipped, which also keeps the audit table out of the schema. Refs: PRD-1668 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (1)
🛟 Help
|
| end | ||
|
|
||
| def fetch_model(model) | ||
| # A collection is named after its model, so an anonymous one (such as the audit trail's) can't be one. |
There was a problem hiding this comment.
Applies to: packages/forest_admin_agent/lib/forest_admin_agent/audit_trail/store.rb:250 (not in this diff)
Claude Opus 5.5 (claude-opus-5-5): Preferential: if the audit store's model is ever given a name, Forest users see the audit table as a collection and no spec fails.
Code
store.rb:250 builds the audit model with Class.new(Sql::AuditLog), and that missing name is now all that keeps the audit table out of the schema.
A way out: assert store.send(:model).name is nil in store_spec.rb, next to the table_name check at line 272.
There was a problem hiding this comment.
Claude Opus 5.5 (claude-opus-5-5): Added keeps its model anonymous to store_spec.rb, which fails if the store ever names its audit model.
The ActiveRecord datasource now skips nameless models, and that is all that keeps the audit table out of the schema, so a spec fails if the store ever names its model. Refs: PRD-1668 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
## [1.46.1](v1.46.0...v1.46.1) (2026-10-16) ### Bug Fixes * **datasource_active_record:** skip anonymous models when building collections ([#413](#413)) ([c721960](c721960))
|
🎉 This PR is included in version 1.46.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

Fixes PRD-1668: a Rails app using the ActiveRecord datasource fails at boot when the audit trail is on.
What changes
Datasource#fetch_modelcalledmodel.name.start_with?on everyActiveRecord::Basedescendant, and the audit trail's anonymousClass.new(Sql::AuditLog)crashed it withundefined method 'start_with?' for nil. After: a model with no name is skipped.datasource_spec.rbbuilds one on an existing table and checks that the datasource boots, leaves it out of the collections, and keeps the named ones.The audit table stays out of the schema because its model is anonymous, and its abstract parents (
AuditConnectionBase,AuditLog) were already skipped.Decisions
Squash message
Definition of Done
General
Security
Note
Fix anonymous model crash in
Datasource#fetch_modelAdds an early return in datasource.rb when an Active Record model has no name. Previously, calling
start_with?on an anonymous model could abort datasource initialization. Named models keep the existing HABTM and collection-registration behavior.Changes since #413 opened
ForestAdminAgent::AuditTrail::Storemaintains an anonymous ActiveRecord model [5a99639]Macroscope summarized c6383b5.