Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version_error_behavior config option #1450

Merged
merged 5 commits into from
Sep 14, 2024

Conversation

modosc
Copy link
Contributor

@modosc modosc commented Nov 16, 2023

NOTE: all the specs pass locally but rubocop is failing on a complexity check - i'm unsure exactly how to simplify this code to satisfy rubocop without making the intent less clear. happy to hear suggestions? for now i've disabled the check around the offending method

Currently when creating a new versioned record an error is raised if the Version cannot be created - this is because #save! is used:

However, when updating, using update_columns, or destroying a versioned record no error is raised if the Version cannot be created:

version = versions_assoc.create(data)

version = @record.class.paper_trail.version_class.create(data)

This pr adds a always_raise_on_error global config option. When set, all of the above failures will raise an error.

Fixes #1449

Thank you for your contribution!

Check the following boxes:

  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@modosc modosc changed the title Add always_raise_on_error config option Add always_raise_on_error config option (fixes #1449) Nov 16, 2023
@modosc modosc changed the title Add always_raise_on_error config option (fixes #1449) Add always_raise_on_error config option Nov 16, 2023
paper_trail.gemspec Outdated Show resolved Hide resolved
Copy link

This PR has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
If this is something you are committed to continue working on, please address any concerns raised by review and/or ping us again.
Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Feb 15, 2024
@modosc
Copy link
Contributor Author

modosc commented Feb 22, 2024

is there any chance of getting this looked at? silently not saving version data is a pretty serious issue imho.

Copy link

This PR has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
If this is something you are committed to continue working on, please address any concerns raised by review and/or ping us again.
Thank you for all your contributions.

@github-actions github-actions bot added the Stale label May 23, 2024
@modosc
Copy link
Contributor Author

modosc commented May 28, 2024

still not stale, still waiting for maintainers to chime in.

or alternately i'm happy to help out if someone wants to add permissions.

@github-actions github-actions bot removed the Stale label May 28, 2024
@jaredbeck
Copy link
Member

Thanks for your contribution.

  • Instead of a boolean configuration option, how about a Symbol, like version_error_behavior: :log # or :exception, :silent
  • Please do not use rubocop: disable comments

i'm unsure exactly how to simplify this code to satisfy rubocop without making the intent less clear.

How about extracting private method(s)?

@modosc
Copy link
Contributor Author

modosc commented Jun 6, 2024

hi @jaredbeck

Instead of a boolean configuration option, how about a Symbol, like version_error_behavior: :log # or :exception, :silent

this would be a breaking change because of how the existing code works since currently an error is raised when creating but not updating. if that's ok then i'm happy to make the change.

@modosc
Copy link
Contributor Author

modosc commented Jun 6, 2024

  • Please do not use rubocop: disable comments

i'm unsure exactly how to simplify this code to satisfy rubocop without making the intent less clear.

How about extracting private method(s)?

done.

Copy link

github-actions bot commented Sep 5, 2024

This PR has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
If this is something you are committed to continue working on, please address any concerns raised by review and/or ping us again.
Thank you for all your contributions.

@github-actions github-actions bot added the Stale label Sep 5, 2024
@modosc
Copy link
Contributor Author

modosc commented Sep 5, 2024

not stale, waiting for reviewers

@jrodden1
Copy link

jrodden1 commented Sep 5, 2024

not stale, waiting for reviewers

+1

I'm pretty sure I've run into this issue with it silently failing and not raising an error. In the past, I only caught it because I happened to watch some :debug console output and then fixed the code that was keeping the version from saving/updating.

It would be rather nice to have this option merged. I would tend to agree with @modosc that this bug when left unfixed causes data integrity / traceability issues and that feels fairly significant. #my2cents

@github-actions github-actions bot removed the Stale label Sep 6, 2024
@jaredbeck
Copy link
Member

Instead of a boolean configuration option, how about a Symbol, like version_error_behavior: :log # or :exception, :silent

this would be a breaking change because of how the existing code works since currently an error is raised when creating but not updating. if that's ok then i'm happy to make the change.

How about version_error_behavior: :legacy # or :log, :exception, :silent? I'd like to have a single, unified configuration option.

@modosc modosc changed the title Add always_raise_on_error config option Add version_error_behavior config option Sep 11, 2024
@modosc
Copy link
Contributor Author

modosc commented Sep 11, 2024

Instead of a boolean configuration option, how about a Symbol, like version_error_behavior: :log # or :exception, :silent

this would be a breaking change because of how the existing code works since currently an error is raised when creating but not updating. if that's ok then i'm happy to make the change.

How about version_error_behavior: :legacy # or :log, :exception, :silent? I'd like to have a single, unified configuration option.

@jaredbeck i've made this change, please take a look. thanks!

Copy link
Member

@jaredbeck jaredbeck left a comment

Choose a reason for hiding this comment

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

Looks great. I appreciate the thorough tests.

@jaredbeck jaredbeck merged commit ff7b398 into paper-trail-gem:master Sep 14, 2024
9 checks passed
@jjb
Copy link

jjb commented Nov 8, 2024

nice - should there be documentation for how to use this in the readme?

@modosc
Copy link
Contributor Author

modosc commented Nov 12, 2024

nice - should there be documentation for how to use this in the readme?

i will try to add some in the next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

errors are not raised when update, update_columns, or destroy versions fail to create
4 participants