Skip to content

Stop swallowing errors from tasks#707

Open
zetter-rpf wants to merge 2 commits intomainfrom
stop-swallowing-errors-from-tasks
Open

Stop swallowing errors from tasks#707
zetter-rpf wants to merge 2 commits intomainfrom
stop-swallowing-errors-from-tasks

Conversation

@zetter-rpf
Copy link
Contributor

We have had lots of intermittent test failures on these tasks. These tasks are all swallowing their errors which makes it difficult to debug (e.g. https://github.com/RaspberryPiFoundation/editor-api/actions/runs/22575865268/job/65394916486 )

We could make the tests output the rails log to standard out or make the log available after but this will make the output hard to match up to the individual test.

Generally we shouldn't swallow errors like this as it makes it difficult to debug and easy for tests to pass for the wrong reasons.

The transaction will work as before as any error raised in a transaction will call a rollback.

We have had lots of intermittent test failures on these tasks. These tasks are all swallowing their errors which makes it difficult to debug.

We could make the tests output the rails log to standard out or make the log available after but this will make the output hard to match up to the individual test.

Generally we shouldn't swallow errors like this as it makes it difficult to debug and easy for tests to pass for the wrong reasons.

The transaction will work as before as any error raised in a transaction will call a rollback.
@cla-bot cla-bot bot added the cla-signed label Mar 2, 2026
@zetter-rpf zetter-rpf marked this pull request as ready for review March 2, 2026 13:50
Copilot AI review requested due to automatic review settings March 2, 2026 13:50
Copy link
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 removes local error-swallowing in seed-related rake tasks so that failures propagate to the caller (tests/CI and the reseed endpoint), making intermittent failures actionable while still preserving transactional rollback behavior.

Changes:

  • Removed rescue StandardError blocks that logged and then raised ActiveRecord::Rollback (which suppresses the original exception).
  • Allowed exceptions inside ActiveRecord::Base.transaction blocks to bubble up naturally (rollback still occurs automatically).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/tasks/test_seeds.rake Stops converting task failures into silent rollbacks; errors now fail the task and surface in output.
lib/tasks/for_education.rake Same change across the for_education seed/destroy tasks to avoid masking failures.

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

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

Test coverage

89.81% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/22579258069

The previous commit caused of the for education tests to fail as it was trying to destroy a school that didn't exist.

This might have been the cause of the intermittent failures as previously if the school didn't exist (but other data did) it would rollback and restore the other data.
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.

2 participants