Skip to content

Conversation

@myabc
Copy link
Contributor

@myabc myabc commented Dec 23, 2025

Ticket

https://community.openproject.org/projects/openproject/work_packages/70243

What are you trying to accomplish?

Fixes a Ruby FrozenError.

Screenshot 2025-12-22 at 20 58 54

Possibly a result of 50be32c / #19980

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@myabc myabc added this to the 17.0.x milestone Dec 23, 2025
@myabc myabc added needs review bugfix ruby Pull requests that update Ruby code labels Dec 23, 2025
@myabc myabc requested review from a team and Copilot December 23, 2025 00:09
@myabc myabc marked this pull request as ready for review December 23, 2025 00:09
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 fixes a FrozenError that occurs when diffing commits. The error happens when attempting to call force_encoding on a frozen string literal without first creating a mutable copy.

Key Changes

  • Added .dup before .force_encoding("UTF-8") in the line_to_html method to handle frozen string literals correctly

Copy link
Contributor

Copilot AI commented Dec 23, 2025

@myabc I've opened a new pull request, #21505, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: myabc <755+myabc@users.noreply.github.com>
@myabc myabc changed the title Fix Frozen error when diffing commits Fix FrozenError when diffing commits Dec 23, 2025
DIFF
end

it "handles frozen strings without raising FrozenError" do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I asked Copilot to generate a spec, but I'm not convinced of its usefulness. I don't think we need to check every method doesn't error with an assertion.

Copy link
Member

Choose a reason for hiding this comment

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

They are totally useless: the tests still pass if we revert back to the old code without calling dup.
Either we find better tests, or we remove them.

What makes the input string with repositories so special that it creates a FrozenError?

Copy link
Member

@cbliard cbliard left a comment

Choose a reason for hiding this comment

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

Tests do not fail if the previous code is used. They should fail.

DIFF
end

it "handles frozen strings without raising FrozenError" do
Copy link
Member

Choose a reason for hiding this comment

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

They are totally useless: the tests still pass if we revert back to the old code without calling dup.
Either we find better tests, or we remove them.

What makes the input string with repositories so special that it creates a FrozenError?

@myabc myabc changed the title Fix FrozenError when diffing commits [#70243] Fix FrozenError when diffing commits Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix DO NOT MERGE ruby Pull requests that update Ruby code

Development

Successfully merging this pull request may close these issues.

3 participants