ruby / ruby/psych

Strange `FrozenError` on `Psych.load`

Open
#659 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

Is it intentional for the following Ruby code to raise FrozenError ?

Psych.safe_load(<<~'end', aliases: true, freeze: true)
  ---
  foo: &foo
    <<: *foo
end

Possibilities:

  • Psych should accept this YAML and properly return a frozen, recursive hash.
  • Psych should raise Psych::AnchorNotDefined instead of FrozenError.
  • FrozenError is the legit exception here.

I have no idea if the YAML in question is valid or not at the first place.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied Psych.safe_load example and determine whether the YAML is valid and how recursive anchors interact with freeze: true. Compare the observed FrozenError with the possible AnchorNotDefined and successful frozen-hash outcomes; done means the behavior is explained and, if needed, covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.