Bug Report
CSV import of production data into staging crashes during IIIF manifest regeneration with:
NoMethodError: undefined method 'resource_id' for nil
core_data_connector/iiif/manifest.rb:121 in 'add_resource'
core_data_connector/iiif/manifest.rb:54 in 'reset_manifests_by_type'
Reported by Camden (2026-03-19) when importing NBU production data.
Root Cause
add_resource in manifest.rb (line 121) calls resource.resource_description.resource_id without nil checks:
hash[key][:resources] << resource.resource_description.resource_id
In reset_manifests_by_type, relationship.related_record (and relationship.primary_record in the related_relationships loop) can return nil when the foreign key points to a deleted record (orphaned relationship). Neither value is checked before being passed to add_resource.
This happens during:
- Data re-import where records are replaced (old records deleted, new ones created, but relationship FKs still point to old IDs)
- Manual record deletion where Relationship rows aren't cascade-deleted
- Merge operations
A secondary nil path: the resource exists but resource.resource_description is nil (MediaContent not yet processed by FairImage).
Relationship to core-data-cloud#546
This looks like a recurrence of #546, but PR #552 (merged 2026-02-24) addressed a different aspect — the import_url_processed column for media re-importing. No nil guard was added to manifest.rb in that fix. The nil dereference has existed since the file was first written.
Recommended Fix
Guard inside add_resource (covers both nil scenarios):
def add_resource(hash, project_model_relationship, resource)
return if resource.nil?
resource_description = resource.resource_description
return if resource_description.nil?
key = project_model_relationship.uuid
hash[key] ||= { id: project_model_relationship.id, name: project_model_relationship.name, resources: [] }
hash[key][:resources] << resource_description.resource_id
end
Bug Report
CSV import of production data into staging crashes during IIIF manifest regeneration with:
Reported by Camden (2026-03-19) when importing NBU production data.
Root Cause
add_resourceinmanifest.rb(line 121) callsresource.resource_description.resource_idwithout nil checks:In
reset_manifests_by_type,relationship.related_record(andrelationship.primary_recordin the related_relationships loop) can return nil when the foreign key points to a deleted record (orphaned relationship). Neither value is checked before being passed toadd_resource.This happens during:
A secondary nil path: the resource exists but
resource.resource_descriptionis nil (MediaContent not yet processed by FairImage).Relationship to core-data-cloud#546
This looks like a recurrence of #546, but PR #552 (merged 2026-02-24) addressed a different aspect — the
import_url_processedcolumn for media re-importing. No nil guard was added tomanifest.rbin that fix. The nil dereference has existed since the file was first written.Recommended Fix
Guard inside
add_resource(covers both nil scenarios):