Skip to content

Fixed config library _default: breaking configs when _definitions: appear below it - fixes #521#1032

Open
philayres wants to merge 1 commit intoconsected:developfrom
hmsrc:library-default-collision-521
Open

Fixed config library _default: breaking configs when _definitions: appear below it - fixes #521#1032
philayres wants to merge 1 commit intoconsected:developfrom
hmsrc:library-default-collision-521

Conversation

@philayres
Copy link
Copy Markdown
Contributor

Summary

Fixes #521 — Adding _default: to a config library breaks configurations if other config library _definitions...: appear below it.

Root Cause

When include_libraries injected library content into a definition's YAML, it renamed _definitions: to _definitions__category_name: to avoid key collisions, but did not rename _default:. This left _default: as a top-level YAML key that absorbed subsequent indented content (such as anchor definitions under _definitions:) as its children, corrupting the YAML structure.

Additionally, when this corruption caused a parse failure, the FphsException was silently caught by option_configs rather than being propagated to all_option_configs_notices, so the admin panel showed no error — making the issue hard to diagnose.

Changes

  • app/models/option_configs/extra_options.rb: Added LibraryKeyRenamePatterns constant listing top-level YAML keys (_definitions, _default) that must be renamed in library content. Updated include_libraries to rename all listed keys, not just _definitions:.
  • app/models/option_configs/config_errors.rb: Added FphsException to the raise_bad_configs list in all_option_configs_notices, so config parse failures are reported as notices in the admin panel.
  • spec/models/option_configs/extra_options_library_default_spec.rb: 4 new specs covering both library ordering permutations, the exact issue Adding _default: to a config library breaks configurations if other config library _definitions...: appear below it #521 scenario, and graceful error handling.

Testing

  • 48/48 specs pass in spec/models/option_configs/ (0 failures)
  • Rubocop: no new offenses in changed files

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.

Adding _default: to a config library breaks configurations if other config library _definitions...: appear below it

1 participant