Skip to content

Fix Options to refuse allowed and subject as option names - #5

Merged
marcoroth merged 1 commit into
mainfrom
option-collision
Aug 25, 2026
Merged

Fix Options to refuse allowed and subject as option names#5
marcoroth merged 1 commit into
mainfrom
option-collision

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request fixes two option names being silently swallowed instead of refused. allowed and subject were keyword parameters on Options.new, so **options could collide with them and they never reached validate!.

Every other unknown option raises. These two quietly reconfigured the validator and then went missing from the JSON that reaches the native library.

LightningCSS.transform(".a {}", nonsense: true)
#=> LightningCSS::OptionError: Unknown option: nonsense

LightningCSS.transform(".a {}", subject: "x")
#=> ".a {\n}\n"

LightningCSS.transform(".a {}", allowed: [:minify])
#=> ".a {\n}\n"

Both are positional arguments now, so no option name can reach them, and the two cases above raise the same way anything else unknown does.

LightningCSS.transform(".a {}", subject: "x")
#=> LightningCSS::OptionError: Unknown option: subject

Breaking change

Options.new and Options.serialize take the options hash as their first argument.

- Options.new(minify: true)
+ Options.new({ minify: true })

- Options.serialize(options, allowed: Options::STYLE_ATTRIBUTE, subject: "a style attribute")
+ Options.serialize(options, Options::STYLE_ATTRIBUTE, "a style attribute")

LightningCSS.transform, bundle, minify and transform_style_attribute are unaffected, so this only reaches code building Options directly.

Neither name was usable as an option before this, since allowed could only narrow what KNOWN already permits and subject only changes the wording of an error. Nothing was silently dropped that a caller could have meant.

@marcoroth
marcoroth enabled auto-merge (squash) August 25, 2026 02:35
@marcoroth
marcoroth merged commit f9f9f9d into main Aug 25, 2026
11 checks passed
@marcoroth
marcoroth deleted the option-collision branch August 25, 2026 02:39
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.

1 participant