Skip to content

Fix serialization error in resource on component publication#15834

Merged
andreslucena merged 21 commits intodevelopfrom
fix/budgets-publication
Feb 18, 2026
Merged

Fix serialization error in resource on component publication#15834
andreslucena merged 21 commits intodevelopfrom
fix/budgets-publication

Conversation

@alecslupu
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu commented Dec 20, 2025

🎩 What? Why?

While trying to replicate the fix for #15830 , i came across the following error:

 1) AdminAccess unpublishes and publishes the component successfully
     Failure/Error: Decidim::RemoveSearchIndexesJob.perform_later(budget.projects)
     
     ActiveJob::SerializationError:
       Unsupported argument type: ActiveRecord::Associations::CollectionProxy
     
     [Screenshot Image]: file:///home/alecslupu/Sites/decidim/develop/spec/decidim_dummy_app/tmp/screenshots/failures_r_spec_example_groups_admin_access_unpublishes_and_publishes_the_component_successfully_472.png

     [Screenshot HTML]: file:///home/alecslupu/Sites/decidim/develop/spec/decidim_dummy_app/tmp/screenshots/failures_r_spec_example_groups_admin_access_unpublishes_and_publishes_the_component_successfully_472.html

     
     Shared Example Group: "when managing a component as an admin" called from /home/alecslupu/Sites/decidim/develop/decidim-dev/lib/decidim/dev/test/rspec_support/component_context.rb:121
     Shared Example Group: "when publishes and unpublishes component" called from ./spec/system/admin_publishes_component_spec.rb:10
     # ./lib/decidim/budgets/component.rb:34:in 'block (3 levels) in <main>'
     # ./lib/decidim/budgets/component.rb:32:in 'block (2 levels) in <main>'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/component_manifest.rb:116:in 'block in Decidim::ComponentManifest#run_hooks'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/component_manifest.rb:115:in 'Array#map'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/component_manifest.rb:115:in 'Decidim::ComponentManifest#run_hooks'
     # /home/alecslupu/Sites/decidim/develop/decidim-admin/app/commands/decidim/admin/unpublish_component.rb:21:in 'Decidim::Admin::UnpublishComponent#call'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/command.rb:19:in 'Decidim::Command.call'
     # /home/alecslupu/Sites/decidim/develop/decidim-admin/app/controllers/decidim/admin/components_controller.rb:117:in 'Decidim::Admin::ComponentsController#unpublish'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/app/controllers/concerns/decidim/use_organization_time_zone.rb:21:in 'Decidim::Admin::ApplicationController#use_organization_time_zone'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/app/controllers/concerns/decidim/locale_switcher.rb:25:in 'Decidim::Admin::ApplicationController#switch_locale'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/middleware/strip_x_forwarded_host.rb:12:in 'Decidim::Middleware::StripXForwardedHost#call'
     # /home/alecslupu/Sites/decidim/develop/decidim-core/lib/decidim/middleware/current_organization.rb:22:in 'Decidim::Middleware::CurrentOrganization#call'
     # /home/alecslupu/Sites/decidim/develop/decidim-dev/lib/decidim/dev/test/map_server.rb:36:in 'Decidim::Dev::Test::MapServer#call'
     # ------------------
     # --- Caused by: ---
     # Capybara::ExpectationNotMet:

📌 Related Issues

Link your PR to an issue

Testing

  1. Login as admin , visit space admin
  2. Go to components & Publish / Unpublish
  3. See error
  4. Apply patch, repeat 2
  5. See no error.

📷 Screenshots

Please add screenshots of the changes you are proposing
Description

♥️ Thank you!

Summary by CodeRabbit

  • Tests

    • Added system tests and shared test flows covering admin publish/unpublish and publication-state cycling across multiple modules.
  • Refactor

    • Search-indexing changed from batched processing to per-record handling; child items are now explicitly enqueued and associated collections are passed as concrete arrays.
  • Behavior

    • Component publish/unpublish now consistently triggers search-index updates or removals across collaborative texts, elections, budgets, accountability, and other modules.

github-actions[bot]
github-actions bot previously approved these changes Dec 20, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an ActiveJob serialization error that occurred when publishing/unpublishing the budgets component. The error was caused by passing an ActiveRecord::Associations::CollectionProxy to ActiveJob, which cannot be serialized. The fix converts the collection to an array using .to_a before passing it to the job.

Key Changes

  • Fixed serialization error in budgets component by converting budget.projects to an array before passing to search index jobs
  • Added test coverage across 10 components to ensure publish/unpublish functionality works correctly
  • Added shared test context "when publishes and unpublishes component" to provide reusable test structure

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
decidim-budgets/lib/decidim/budgets/component.rb Fixed ActiveJob serialization by converting budget.projects to array in publish/unpublish hooks
decidim-dev/lib/decidim/dev/test/rspec_support/component_context.rb Added shared test context for testing component publish/unpublish functionality
decidim-accountability/spec/system/admin/admin_publishes_component_spec.rb Added test for accountability component publish/unpublish
decidim-blogs/spec/system/admin_publishes_component_spec.rb Added test for blogs component publish/unpublish
decidim-budgets/spec/system/admin_publishes_component_spec.rb Added test for budgets component publish/unpublish
decidim-collaborative_texts/spec/system/admin/admin_publishes_component_spec.rb Added test for collaborative_texts component publish/unpublish
decidim-debates/spec/system/admin_publishes_component_spec.rb Added test for debates component publish/unpublish
decidim-elections/spec/system/admin/admin_publishes_component_spec.rb Added test for elections component publish/unpublish
decidim-meetings/spec/system/admin/admin_publishes_component_spec.rb Added test for meetings component publish/unpublish
decidim-pages/spec/system/admin_publishes_component_spec.rb Added test for pages component publish/unpublish
decidim-proposals/spec/system/admin/admin_publishes_component_spec.rb Added test for proposals component publish/unpublish
decidim-surveys/spec/system/admin_publishes_component_spec.rb Added test for surveys component publish/unpublish

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes Dec 20, 2025
@alecslupu alecslupu assigned alecslupu and unassigned andreslucena Dec 24, 2025
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes Jan 12, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 13, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 13, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 13, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 13, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 13, 2026
@alecslupu
Copy link
Copy Markdown
Contributor Author

@andreslucena seems to be ready again ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants