Skip to content

Fix importing attachments within processes/assemblies#16202

Merged
alecslupu merged 2 commits intodevelopfrom
fix/import-spaces-200-attachments
Mar 2, 2026
Merged

Fix importing attachments within processes/assemblies#16202
alecslupu merged 2 commits intodevelopfrom
fix/import-spaces-200-attachments

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Feb 24, 2026

🎩 What? Why?

Yet another fix related to the export/import feature in spaces.

This time the problem is when the attachments are actually available (i.e. a status code 200). There's an error with the TMP file that we have as content type, when ActiveStorage actually needs a Content Type for these files to be imported.

📌 Related Issues

Testing

  1. Sign in as admin
  2. Export a process or assembly
  3. Go to http://localhost:3000/admin/participatory_processes/imports/new
  4. Fill a title, a slug and upload that JSON
  5. (Before this PR) there's an exception
  6. (After this PR) the process is imported correctly

Stacktrace

ArgumentError (Could not find or build blob: expected attachable, got #<Tempfile:/tmp/open-uri20260224-57523-krhegm>):

activestorage (7.2.3) lib/active_storage/attached/changes/create_one.rb:112:in 'ActiveStorage::Attached::Changes::CreateOne#find_or_build_blob'
activestorage (7.2.3) lib/active_storage/attached/changes/create_one.rb:20:in 'ActiveStorage::Attached::Changes::CreateOne#blob'
activestorage (7.2.3) lib/active_storage/attached/changes/create_one.rb:12:in 'ActiveStorage::Attached::Changes::CreateOne#initialize'
activestorage (7.2.3) lib/active_storage/attached/model.rb:121:in 'Class#new'
activestorage (7.2.3) lib/active_storage/attached/model.rb:121:in 'Decidim::Attachment::GeneratedAssociationMethods#file='
activemodel (7.2.3) lib/active_model/attribute_assignment.rb:48:in 'Kernel#public_send'
activemodel (7.2.3) lib/active_model/attribute_assignment.rb:48:in 'ActiveModel::AttributeAssignment#_assign_attribute'
activerecord (7.2.3) lib/active_record/attribute_assignment.rb:17:in 'block in ActiveRecord::AttributeAssignment#_assign_attributes'
activerecord (7.2.3) lib/active_record/attribute_assignment.rb:9:in 'Hash#each'
activerecord (7.2.3) lib/active_record/attribute_assignment.rb:9:in 'ActiveRecord::AttributeAssignment#_assign_attributes'
activemodel (7.2.3) lib/active_model/attribute_assignment.rb:34:in 'ActiveModel::AttributeAssignment#assign_attributes'
activemodel (7.2.3) lib/active_model/api.rb:81:in 'ActiveModel::API#initialize'
activerecord (7.2.3) lib/active_record/core.rb:470:in 'ActiveRecord::Core#initialize'
activerecord (7.2.3) lib/active_record/inheritance.rb:76:in 'Class#new'
activerecord (7.2.3) lib/active_record/inheritance.rb:76:in 'ActiveRecord::Inheritance::ClassMethods#new'
/workspaces/decidim/decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb:121:in 'block (2 levels) in Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter#import_folders_and_attachments'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:64:in 'block (2 levels) in Decidim::Traceability#perform_action!'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/database_statements.rb:359:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#transaction'
activerecord (7.2.3) lib/active_record/transactions.rb:234:in 'block in ActiveRecord::Transactions::ClassMethods#transaction'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:425:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'
activerecord (7.2.3) lib/active_record/connection_handling.rb:298:in 'ActiveRecord::ConnectionHandling#with_connection'
activerecord (7.2.3) lib/active_record/transactions.rb:233:in 'ActiveRecord::Transactions::ClassMethods#transaction'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:63:in 'block in Decidim::Traceability#perform_action!'
paper_trail (16.0.0) lib/paper_trail/request.rb:85:in 'PaperTrail::Request.with'
paper_trail (16.0.0) lib/paper_trail.rb:81:in 'PaperTrail.request'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:62:in 'Decidim::Traceability#perform_action!'
/workspaces/decidim/decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb:120:in 'block in Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter#import_folders_and_attachments'
/workspaces/decidim/decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb:95:in 'Array#map'
/workspaces/decidim/decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb:95:in 'Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter#import_folders_and_attachments'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:46:in 'block (2 levels) in Decidim::ParticipatoryProcesses::Admin::ImportParticipatoryProcess#import_participatory_process'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:64:in 'block (2 levels) in Decidim::Traceability#perform_action!'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/database_statements.rb:359:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#transaction'
activerecord (7.2.3) lib/active_record/transactions.rb:234:in 'block in ActiveRecord::Transactions::ClassMethods#transaction'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:425:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'
activerecord (7.2.3) lib/active_record/connection_handling.rb:298:in 'ActiveRecord::ConnectionHandling#with_connection'
activerecord (7.2.3) lib/active_record/transactions.rb:233:in 'ActiveRecord::Transactions::ClassMethods#transaction'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:63:in 'block in Decidim::Traceability#perform_action!'
paper_trail (16.0.0) lib/paper_trail/request.rb:85:in 'PaperTrail::Request.with'
paper_trail (16.0.0) lib/paper_trail.rb:81:in 'PaperTrail.request'
/workspaces/decidim/decidim-core/app/services/decidim/traceability.rb:62:in 'Decidim::Traceability#perform_action!'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:43:in 'block in Decidim::ParticipatoryProcesses::Admin::ImportParticipatoryProcess#import_participatory_process'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:41:in 'Array#each'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:41:in 'Decidim::ParticipatoryProcesses::Admin::ImportParticipatoryProcess#import_participatory_process'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:28:in 'block in Decidim::ParticipatoryProcesses::Admin::ImportParticipatoryProcess#call'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:616:in 'block in ActiveRecord::ConnectionAdapters::TransactionManager#within_new_transaction'
activesupport (7.2.3) lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:613:in 'ActiveRecord::ConnectionAdapters::TransactionManager#within_new_transaction'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/database_statements.rb:361:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#transaction'
activerecord (7.2.3) lib/active_record/transactions.rb:234:in 'block in ActiveRecord::Transactions::ClassMethods#transaction'
activerecord (7.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:431:in 'ActiveRecord::ConnectionAdapters::ConnectionPool#with_connection'
activerecord (7.2.3) lib/active_record/connection_handling.rb:298:in 'ActiveRecord::ConnectionHandling#with_connection'
activerecord (7.2.3) lib/active_record/transactions.rb:233:in 'ActiveRecord::Transactions::ClassMethods#transaction'
/workspaces/decidim/decidim-core/lib/decidim/command.rb:30:in 'Decidim::Command#transaction'
/workspaces/decidim/decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb:27:in 'Decidim::ParticipatoryProcesses::Admin::ImportParticipatoryProcess#call'
/workspaces/decidim/decidim-core/lib/decidim/command.rb:19:in 'Decidim::Command.call'
/workspaces/decidim/decidim-participatory_processes/app/controllers/decidim/participatory_processes/admin/participatory_process_imports_controller.rb:20:in 'Decidim::ParticipatoryProcesses::Admin::ParticipatoryProcessImportsController#create'

📷 Screenshots

image

♥️ Thank you!

Summary by CodeRabbit

  • Bug Fixes

    • Remote file imports now assign remote URLs, derive content type/size from responses, and gracefully catch network/download errors—logging attachment warnings and skipping failed files.
  • Tests

    • Added tests for successful PDF/image remote imports, plus edge cases for blank or nil file references and content-type/size validation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b748147 and f01a6be.

📒 Files selected for processing (2)
  • decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb
  • decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb

📝 Walkthrough

Walkthrough

Replaces direct URI.open downloads in assemblies and participatory process importers with uploader remote_url assignment and set_content_type_and_size calls, wrapped in network-error rescue that logs attachment warnings and skips failed remote files; tests added for successful remote PDF/JPEG imports and edge cases.

Changes

Cohort / File(s) Summary
Assembly Importer
decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb
Remove direct URI.open file download; assign attached_uploader(:file).remote_url = url, call set_content_type_and_size, and rescue network/open-uri errors, emitting attachment_error warnings and skipping failures.
Assembly Importer Tests
decidim-assemblies/spec/serializers/decidim/assemblies/assembly_importer_spec.rb
Add tests for remote-file success (PDF, JPEG), content-type/size assertions, and edge cases (blank URL, nil files).
Participatory Process Importer
decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb
Same refactor as assemblies: replace in-place URI.open with remote_url assignment + set_content_type_and_size, wrap in rescue for network errors and log warnings.
Participatory Process Tests
decidim-participatory_processes/spec/serializers/decidim/participatory_processes/participatory_process_importer_spec.rb
Add parallel tests covering remote PDF/JPEG success paths, metadata checks, and blank/nil input edge cases.

Sequence Diagram(s)

sequenceDiagram
  participant Importer
  participant HTTP as Remote HTTP
  participant Uploader
  participant DB as Attachment Model

  Importer->>HTTP: HEAD /file_url (fetch_content_type)
  alt HEAD returns Content-Type
    HTTP-->>Importer: Content-Type (e.g., application/pdf)
    Importer->>Uploader: set remote_url = file_url
    alt remote_url assignment succeeds
      Uploader-->>Importer: set_content_type_and_size (content_type, size)
      Importer->>DB: create/save Attachment (with content_type, size, weight)
      DB-->>Importer: saved
    else remote_url assignment fails (network error)
      Uploader-->>Importer: raises network error
      Importer-->>Importer: log attachment_error warning, skip file
    end
  else HEAD fails or no Content-Type
    HTTP-->>Importer: error / nil
    Importer->>Uploader: set remote_url = file_url (attempt)
    Uploader-->>Importer: may succeed with unknown content_type
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • alecslupu

Poem

🐰 Hopping bytes across the net so light,
HEADs first peek to fetch the MIME right,
Remote URLs snug in uploader's care,
If storms arise, a gentle warning's there,
Attachments land — hop, hop, import delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main fix: resolving attachment import failures in processes and assemblies by addressing the Content Type issue.
Linked Issues check ✅ Passed The changes directly address issue #10180 by implementing remote URL handling and proper content-type/size detection, enabling attachment imports to succeed.
Out of Scope Changes check ✅ Passed All changes are strictly scoped to fixing attachment import failures in the two importers and their corresponding test suites, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/import-spaces-200-attachments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

github-actions[bot]
github-actions bot previously approved these changes Feb 24, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (5)
decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb (2)

199-214: Add timeouts to prevent indefinite blocking.

Same concern as flagged on ParticipatoryProcessImporter#fetch_content_type — the Net::HTTP connection here lacks explicit open_timeout and read_timeout, risking indefinite hangs on unresponsive servers.

🛡️ Proposed fix
         uri = URI.parse(url)
         http_connection = Net::HTTP.new(uri.host, uri.port)
         http_connection.use_ssl = true if uri.scheme == "https"
+        http_connection.open_timeout = 5
+        http_connection.read_timeout = 5
         http_connection.start do |http|
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb`
around lines 199 - 214, The fetch_content_type method currently creates a
Net::HTTP instance without timeouts which can hang; update the Net::HTTP object
(in Assemblies::AssemblyImporter#fetch_content_type) to set explicit
open_timeout and read_timeout (e.g. open_timeout = 5, read_timeout = 10) before
starting the connection, keep the existing use_ssl logic, and preserve the
existing response handling and rescue behavior so unresponsive hosts time out
instead of blocking indefinitely.

70-108: Same double-HEAD-request concern as in ParticipatoryProcessImporter.

The remote_file_error(url) call at line 77 and fetch_content_type(url) at line 93 each issue a separate HTTP HEAD request to the same URL. See the recommendation on the parallel ParticipatoryProcessImporter for a merged approach that avoids the redundant round-trip.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb`
around lines 70 - 108, The importer makes two separate HEAD requests for the
same URL (remote_file_error and fetch_content_type) causing redundant network
calls; change import_folders_and_attachments to perform a single HEAD fetch
(e.g. via a new helper fetch_remote_file_head or by updating remote_file_error
to return both error and headers) and reuse its result: call that helper once
per url, check the returned error and push a warning if present, and pass the
retrieved content_type/header info into Attachment.new (content_type) instead of
calling fetch_content_type again; adjust error handling around the single HEAD
call to preserve the existing rescue behavior used when assigning
attached_uploader(:file).remote_url.
decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb (3)

227-241: Substantial code duplication with AssemblyImporter.

fetch_content_type, format_error, remote_file_error, attachment_title, and the bulk of import_folders_and_attachments are near-identical copies between this file and decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb. This makes future maintenance error-prone — a fix in one importer can easily be forgotten in the other.

Consider extracting the shared logic into a common module/concern (e.g., Decidim::Importers::RemoteAttachmentHandling) that both importers include. This could be done as a follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb`
around lines 227 - 241, The two importer classes
(Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter and
Decidim::Assemblies::AssemblyImporter) duplicate methods like
fetch_content_type, format_error, remote_file_error, attachment_title and large
parts of import_folders_and_attachments; extract these shared behaviors into a
single concern/module (suggested name:
Decidim::Importers::RemoteAttachmentHandling) that implements those methods and
any helper logic, then have both importers include that module and delegate to
its methods (replace local method definitions in ParticipatoryProcessImporter
and AssemblyImporter with includes/calls to the new module) so future fixes are
made in one place.

92-130: Double HTTP HEAD request per attachment — consider merging remote_file_error and fetch_content_type.

For each attachment, remote_file_error(url) (line 99) issues an HTTP HEAD request, and then fetch_content_type(url) (line 115) issues a second HEAD request to the same URL. This doubles the network round-trips for every imported attachment.

Consider refactoring remote_file_error to return both the error and the content type from a single HEAD request, e.g., returning a struct/hash like { error: nil, content_type: "application/pdf" }.

♻️ Sketch of a merged approach
-          error = remote_file_error(url)
-          if error.present?
+          file_info = remote_file_info(url)
+          if file_info[:error].present?
             `@warnings` << I18n.t(
               "decidim.participatory_processes.admin.imports.attachment_error",
               title: attachment_title(file),
-              error:
+              error: file_info[:error]
             )
             next
           end
 
           Decidim.traceability.perform_action!("create", Attachment, `@user`) do
             attachment = Attachment.new(
               title: file["title"],
               description: file["description"],
               attached_to: `@imported_process`,
               weight: file["weight"],
-              content_type: fetch_content_type(url)
+              content_type: file_info[:content_type]
             )

Where remote_file_info does a single HEAD and returns both pieces of data.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb`
around lines 92 - 130, The import currently calls remote_file_error(url) and
then fetch_content_type(url), causing two HTTP HEADs per attachment; change to
perform a single HEAD by adding a combined helper (e.g., remote_file_info or
remote_head_for_attachment) that returns both error and content_type (e.g., {
error: ..., content_type: ... }) and update import_folders_and_attachments to
call that helper once, use the returned :error to push warnings (preserving
format_error handling) and the returned :content_type when building the
Attachment (replace fetch_content_type(url) with the returned value); keep
existing rescue logic around assigning remote_url and the attachment creation
flow.

227-241: Missing timeouts on the HTTP connection — risk of indefinite blocking.

Net::HTTP.new without explicit open_timeout / read_timeout uses Ruby's default (which is effectively no timeout for open_timeout in older Rubies, and 60s for read_timeout). If the remote server is slow or unresponsive, this can block the import thread for a long time or indefinitely.

The same concern applies to remote_file_error (lines 175-176), but since that's pre-existing code, flagging it here for the new method.

🛡️ Proposed fix
         uri = URI.parse(url)
         http_connection = Net::HTTP.new(uri.host, uri.port)
         http_connection.use_ssl = true if uri.scheme == "https"
+        http_connection.open_timeout = 5
+        http_connection.read_timeout = 5
         http_connection.start do |http|
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb`
around lines 227 - 241, The fetch_content_type method creates a Net::HTTP
connection without timeouts causing potential indefinite blocking; update
fetch_content_type to set explicit open_timeout and read_timeout on the
Net::HTTP instance created in URI.parse (e.g., when calling
Net::HTTP.new(uri.host, uri.port)) and pass reasonable values (for example a few
seconds) before calling http.start and http.head; ensure the same pattern
(explicit open_timeout/read_timeout) is applied to the earlier remote_file_error
HTTP usage to avoid the same blocking issue.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb`:
- Around line 199-214: The fetch_content_type method currently creates a
Net::HTTP instance without timeouts which can hang; update the Net::HTTP object
(in Assemblies::AssemblyImporter#fetch_content_type) to set explicit
open_timeout and read_timeout (e.g. open_timeout = 5, read_timeout = 10) before
starting the connection, keep the existing use_ssl logic, and preserve the
existing response handling and rescue behavior so unresponsive hosts time out
instead of blocking indefinitely.
- Around line 70-108: The importer makes two separate HEAD requests for the same
URL (remote_file_error and fetch_content_type) causing redundant network calls;
change import_folders_and_attachments to perform a single HEAD fetch (e.g. via a
new helper fetch_remote_file_head or by updating remote_file_error to return
both error and headers) and reuse its result: call that helper once per url,
check the returned error and push a warning if present, and pass the retrieved
content_type/header info into Attachment.new (content_type) instead of calling
fetch_content_type again; adjust error handling around the single HEAD call to
preserve the existing rescue behavior used when assigning
attached_uploader(:file).remote_url.

In
`@decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb`:
- Around line 227-241: The two importer classes
(Decidim::ParticipatoryProcesses::ParticipatoryProcessImporter and
Decidim::Assemblies::AssemblyImporter) duplicate methods like
fetch_content_type, format_error, remote_file_error, attachment_title and large
parts of import_folders_and_attachments; extract these shared behaviors into a
single concern/module (suggested name:
Decidim::Importers::RemoteAttachmentHandling) that implements those methods and
any helper logic, then have both importers include that module and delegate to
its methods (replace local method definitions in ParticipatoryProcessImporter
and AssemblyImporter with includes/calls to the new module) so future fixes are
made in one place.
- Around line 92-130: The import currently calls remote_file_error(url) and then
fetch_content_type(url), causing two HTTP HEADs per attachment; change to
perform a single HEAD by adding a combined helper (e.g., remote_file_info or
remote_head_for_attachment) that returns both error and content_type (e.g., {
error: ..., content_type: ... }) and update import_folders_and_attachments to
call that helper once, use the returned :error to push warnings (preserving
format_error handling) and the returned :content_type when building the
Attachment (replace fetch_content_type(url) with the returned value); keep
existing rescue logic around assigning remote_url and the attachment creation
flow.
- Around line 227-241: The fetch_content_type method creates a Net::HTTP
connection without timeouts causing potential indefinite blocking; update
fetch_content_type to set explicit open_timeout and read_timeout on the
Net::HTTP instance created in URI.parse (e.g., when calling
Net::HTTP.new(uri.host, uri.port)) and pass reasonable values (for example a few
seconds) before calling http.start and http.head; ensure the same pattern
(explicit open_timeout/read_timeout) is applied to the earlier remote_file_error
HTTP usage to avoid the same blocking issue.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b9ef1c and acd2bd2.

📒 Files selected for processing (3)
  • decidim-assemblies/app/serializers/decidim/assemblies/assembly_importer.rb
  • decidim-assemblies/spec/serializers/decidim/assemblies/assembly_importer_spec.rb
  • decidim-participatory_processes/app/serializers/decidim/participatory_processes/participatory_process_importer.rb

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 24, 2026
@andreslucena andreslucena force-pushed the fix/import-spaces-200-attachments branch from acd2bd2 to b748147 Compare February 24, 2026 16:28
github-actions[bot]
github-actions bot previously approved these changes Feb 24, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 24, 2026
@andreslucena
Copy link
Copy Markdown
Member Author

This is ready for the review @alecslupu

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

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

I would have code change, that would reduce the spaghetti code. Tested on my local, and seems to be working fine.

@andreslucena
Copy link
Copy Markdown
Member Author

This is ready for another round @alecslupu

@andreslucena andreslucena dismissed alecslupu’s stale review February 26, 2026 12:25

Ready for another!

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

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

👍 - Merging with QLTY pipeline error on coverage.

@alecslupu alecslupu added release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 labels Mar 2, 2026
@alecslupu alecslupu merged commit 85eae54 into develop Mar 2, 2026
58 of 67 checks passed
@alecslupu alecslupu deleted the fix/import-spaces-200-attachments branch March 2, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: assemblies module: participatory processes release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attachments are not imported when importing participatory process

2 participants