Skip to content

Reflect Ruby 3.4 stack trace changes #100

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

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

ekohl
Copy link
Contributor

@ekohl ekohl commented Jun 4, 2025

Ruby 3.4 changed the stack frame formatting and that meant it no longer recognized the Puppet stack frames. This updates the regex for the new format.

This provides a better failure message.
@ekohl
Copy link
Contributor Author

ekohl commented Jun 4, 2025

Documenting my findings.

We have this code:

def raise_error(exception_class)
case exception_class
when Puppet::ParseErrorWithIssue
raise exception_class.new('Oops', '/tmp/test.pp', 30, 15, nil, :SYNTAX_ERROR)
when Puppet::ParseError
raise exception_class.new('Oops', '/tmp/test.pp', 30, 15)
else
raise exception_class.new('Oops')
end
end

But that can never work because that's not how you match exceptions. Minimal reproducer:

class MyException < StandardError; end

def raise_error(exception_class)
  case exception_class
  when MyException
    puts 'Match'
  else
    puts 'No match'
  end
end

raise_error(MyException)

This is because even RuntimeError === RuntimeError returns false.

But that just means it's equivalent to raise exception_class.new('Oops') which is still an instance of Puppet::ParseErrorWithIssue.

My feeling is that one of https://rubyreferences.github.io/rubychanges/3.4.html#backtrace-related-changes has an effect on this, but I can't figure out what.

Ruby 3.4 changed the stack frame formatting and that meant it no longer
recognized the Puppet stack frames. This updates the regex for the new
format.
@ekohl ekohl changed the title Fix Ruby 3.4 test failures Reflect Ruby 3.4 stack trace changes Jun 5, 2025
@ekohl ekohl marked this pull request as ready for review June 5, 2025 07:24
@ekohl ekohl added the bug Something isn't working label Jun 5, 2025
@bastelfreak bastelfreak merged commit 6bf84d6 into OpenVoxProject:main Jun 5, 2025
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants