Datasets:
Download data/instances.csv from ramachandra1996/agentconflictbench: direct link, hf CLI and curl.
- Browser
- Download file 163 kB
-
https://huggingface.co/datasets/ramachandra1996/agentconflictbench/resolve/main/data/instances.csv
- Command line
-
hf download hf://datasets/ramachandra1996/agentconflictbench/data/instances.csv
-
curl -L -o instances.csv https://huggingface.co/datasets/ramachandra1996/agentconflictbench/resolve/main/data/instances.csv
163 kB
| id,repo,base_commit,language,conflict_type,composition_expected,difficulty,source,status,task_a,task_b,task_a_summary,task_b_summary,patch_a,patch_b,combined_patch,oracle_patch_a_path,oracle_patch_b_path,oracle_composition_path,oracle_patch_a,oracle_patch_b,oracle_composition,validation_a,validation_b,validation_composed,merge_result,failure_summary,notes,github_instance_path | |
| click__001,https://github.com/pallets/click,2c8cd3ac958a7eb316d67f2d316c27086c4c0369,Python,configuration,fail,easy,researcher_constructed,reproduced,"# Task A: Dashed default-map option aliases | |
| ## Problem | |
| Click stores option parameter names internally with underscores, but users often | |
| write configuration files with CLI-style dashed keys such as `api-key`. | |
| ## Desired behavior | |
| Allow `Context.default_map` to resolve dashed option names as aliases for their | |
| underscored parameter names. | |
| ## Constraints | |
| Existing underscored keys must continue to work. The change should only affect | |
| default-map lookup and should not alter command-line parsing or environment | |
| variable naming. | |
| ## Success criteria | |
| A command option declared as `--api-key` can receive its default from either | |
| `{""api_key"": ""...""}` or `{""api-key"": ""...""}` in `default_map`. | |
| ","# Task B: Default-map precedence over auto envvars | |
| ## Problem | |
| When both automatic environment variables and `default_map` are available, | |
| applications may need explicit configuration-map values to override ambient | |
| environment settings. | |
| ## Desired behavior | |
| Update option resolution so a value from `Context.default_map` takes precedence | |
| over an automatically derived environment variable value. | |
| ## Constraints | |
| Explicit command-line arguments must still have the highest precedence. The | |
| change should apply to automatically derived envvars, not necessarily every | |
| custom envvar path. | |
| ## Success criteria | |
| If `APP_API_KEY` is set and `default_map` also provides `api_key`, the command | |
| uses the `default_map` value when no CLI argument is supplied. | |
| ","Allow Context.default_map to use dashed option names, such as api-key, as aliases for Click's internal underscored parameter names, such as api_key.",Allow Context.default_map values to override automatically derived environment variable values during option resolution.,"diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..2df26c7 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -765,6 +765,13 @@ class Context: | |
| ``name`` is ``None``, or the stored value is the internal | |
| :data:`UNSET` sentinel. | |
| """""" | |
| + if ( | |
| + name is not None | |
| + and self.default_map is not None | |
| + and name not in self.default_map | |
| + ): | |
| + name = name.replace(""_"", ""-"") | |
| + | |
| return ( | |
| name is not None | |
| and self.default_map is not None | |
| @@ -797,6 +804,9 @@ class Context: | |
| # Assert to make the type checker happy. | |
| assert self.default_map is not None | |
| + if name not in self.default_map: | |
| + name = name.replace(""_"", ""-"") | |
| + | |
| value = self.default_map[name] | |
| if call and callable(value): | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..d6d4a16 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -2501,12 +2501,6 @@ class Parameter(ABC): | |
| else ParameterSource.DEFAULT | |
| ) | |
| - if value is UNSET: | |
| - envvar_value = self.value_from_envvar(ctx) | |
| - if envvar_value is not None: | |
| - value = envvar_value | |
| - source = ParameterSource.ENVIRONMENT | |
| - | |
| if value is UNSET: | |
| default_map_value = ctx.lookup_default(self.name) | |
| if default_map_value is not None or ctx._default_map_has(self.name): | |
| @@ -2518,6 +2512,12 @@ class Parameter(ABC): | |
| if isinstance(value, str) and self.nargs != 1: | |
| value = self.type.split_envvar_value(value) | |
| + if value is UNSET: | |
| + envvar_value = self.value_from_envvar(ctx) | |
| + if envvar_value is not None: | |
| + value = envvar_value | |
| + source = ParameterSource.ENVIRONMENT | |
| + | |
| if value is UNSET: | |
| default_value = self.get_default(ctx) | |
| if default_value is not UNSET: | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..049be89 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -765,6 +765,13 @@ class Context: | |
| ``name`` is ``None``, or the stored value is the internal | |
| :data:`UNSET` sentinel. | |
| """""" | |
| + if ( | |
| + name is not None | |
| + and self.default_map is not None | |
| + and name not in self.default_map | |
| + ): | |
| + name = name.replace(""_"", ""-"") | |
| + | |
| return ( | |
| name is not None | |
| and self.default_map is not None | |
| @@ -797,6 +804,9 @@ class Context: | |
| # Assert to make the type checker happy. | |
| assert self.default_map is not None | |
| + if name not in self.default_map: | |
| + name = name.replace(""_"", ""-"") | |
| + | |
| value = self.default_map[name] | |
| if call and callable(value): | |
| @@ -2501,12 +2511,6 @@ class Parameter(ABC): | |
| else ParameterSource.DEFAULT | |
| ) | |
| - if value is UNSET: | |
| - envvar_value = self.value_from_envvar(ctx) | |
| - if envvar_value is not None: | |
| - value = envvar_value | |
| - source = ParameterSource.ENVIRONMENT | |
| - | |
| if value is UNSET: | |
| default_map_value = ctx.lookup_default(self.name) | |
| if default_map_value is not None or ctx._default_map_has(self.name): | |
| @@ -2518,6 +2522,12 @@ class Parameter(ABC): | |
| if isinstance(value, str) and self.nargs != 1: | |
| value = self.type.split_envvar_value(value) | |
| + if value is UNSET: | |
| + envvar_value = self.value_from_envvar(ctx) | |
| + if envvar_value is not None: | |
| + value = envvar_value | |
| + source = ParameterSource.ENVIRONMENT | |
| + | |
| if value is UNSET: | |
| default_value = self.get_default(ctx) | |
| if default_value is not UNSET: | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import click | |
| from click.testing import CliRunner | |
| def test_default_map_accepts_dashed_option_name(): | |
| @click.command() | |
| @click.option(""--api-key"") | |
| def cli(api_key): | |
| click.echo(api_key) | |
| result = CliRunner().invoke(cli, [], default_map={""api-key"": ""from-map""}) | |
| assert result.output == ""from-map\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_default_map_overrides_auto_envvar(): | |
| @click.command() | |
| @click.option(""--api-key"") | |
| def cli(api_key): | |
| click.echo(api_key) | |
| result = CliRunner().invoke( | |
| cli, | |
| [], | |
| auto_envvar_prefix=""APP"", | |
| default_map={""api_key"": ""from-map""}, | |
| env={""APP_API_KEY"": ""from-env""}, | |
| ) | |
| assert result.output == ""from-map\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_dashed_default_map_alias_does_not_override_auto_envvar(): | |
| @click.command() | |
| @click.option(""--api-key"") | |
| def cli(api_key): | |
| click.echo(api_key) | |
| result = CliRunner().invoke( | |
| cli, | |
| [], | |
| auto_envvar_prefix=""APP"", | |
| default_map={""api-key"": ""from-map""}, | |
| env={""APP_API_KEY"": ""from-env""}, | |
| ) | |
| assert result.output == ""from-env\n"" | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A broadens default_map lookup to treat dashed keys as aliases. Patch B gives default_map higher precedence than auto envvars. Together, a dashed default_map alias unexpectedly overrides APP_API_KEY, changing the composed command output from from-env to from-map.",Seed instance used to validate the AgentConflictBench packaging and oracle format. This is a controlled configuration-precedence conflict in Click option resolution.,instances/click__001 | |
| click__002,https://github.com/pallets/click,2c8cd3ac958a7eb316d67f2d316c27086c4c0369,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Underscore aliases for dashed command names | |
| ## Problem | |
| Click commands are commonly registered with dashed names, but users sometimes | |
| type underscores when invoking command names from scripts or generated tools. | |
| ## Desired behavior | |
| Allow command lookup to treat underscores in an invoked command name as aliases | |
| for dashes in registered command names. | |
| ## Constraints | |
| Exact command-name matches should keep their current behavior. The alias should | |
| only be used as a fallback when the invoked name is not found directly. | |
| ## Success criteria | |
| A group containing `foo-bar` can resolve an invocation of `foo_bar` to the same | |
| command. | |
| ","# Task B: Lowercase fallback for command lookup | |
| ## Problem | |
| Users may invoke commands with accidental uppercase or mixed-case spelling even | |
| when the registered command name is lowercase. | |
| ## Desired behavior | |
| Allow command lookup to fall back to a lowercase command name when the original | |
| invocation is not found exactly. | |
| ## Constraints | |
| Exact case-sensitive matches must continue to win. The fallback should not | |
| change command registration or display names. | |
| ## Success criteria | |
| A group containing `status` can resolve an invocation of `STATUS` to the | |
| registered command. | |
| ",Allow command lookup to treat underscores in an invoked command name as aliases for dashes in registered command names.,Allow command lookup to fall back to lowercase command names when a mixed-case or uppercase command invocation is not found exactly.,"diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..5e040ce 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1938,7 +1938,12 @@ class Group(Command): | |
| """"""Given a context and a command name, this returns a :class:`Command` | |
| object if it exists or returns ``None``. | |
| """""" | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is None: | |
| + cmd = self.commands.get(cmd_name.replace(""_"", ""-"")) | |
| + | |
| + return cmd | |
| def list_commands(self, ctx: Context) -> list[str]: | |
| """"""Returns a list of subcommand names in the order they should appear."""""" | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..cb1467c 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -2077,6 +2077,13 @@ class Group(Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| # If we don't find the command we want to show an error message | |
| # to the user that it was not provided. However, there is | |
| # something else we should do: if the first argument looks like | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..b49d8b3 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1938,7 +1938,12 @@ class Group(Command): | |
| """"""Given a context and a command name, this returns a :class:`Command` | |
| object if it exists or returns ``None``. | |
| """""" | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is None: | |
| + cmd = self.commands.get(cmd_name.replace(""_"", ""-"")) | |
| + | |
| + return cmd | |
| def list_commands(self, ctx: Context) -> list[str]: | |
| """"""Returns a list of subcommand names in the order they should appear."""""" | |
| @@ -2077,6 +2082,13 @@ class Group(Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| # If we don't find the command we want to show an error message | |
| # to the user that it was not provided. However, there is | |
| # something else we should do: if the first argument looks like | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import click | |
| from click.testing import CliRunner | |
| def test_underscore_invocation_resolves_dashed_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""foo-bar"") | |
| def foo_bar(): | |
| click.echo(""dash"") | |
| result = CliRunner().invoke(cli, [""foo_bar""]) | |
| assert result.output == ""dash\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_uppercase_invocation_resolves_lowercase_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""status"") | |
| def status(): | |
| click.echo(""ok"") | |
| result = CliRunner().invoke(cli, [""STATUS""]) | |
| assert result.output == ""ok\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_uppercase_underscore_does_not_transitively_resolve_dashed_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""foo-bar"") | |
| def foo_bar(): | |
| click.echo(""dash"") | |
| result = CliRunner().invoke(cli, [""FOO_BAR""]) | |
| assert result.exit_code != 0 | |
| assert ""No such command 'foo_bar'"" in result.output | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A introduces underscore-to-dash command aliasing. Patch B introduces case-insensitive fallback lookup. Together, they create an unintended transitive lookup where FOO_BAR resolves to foo-bar, even though neither patch independently admits that invocation form.",Second seed instance. This demonstrates a behavioral command-resolution conflict rather than a configuration-precedence conflict.,instances/click__002 | |
| click__003,https://github.com/pallets/click,2c8cd3ac958a7eb316d67f2d316c27086c4c0369,Python,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Reflect explicit registration aliases on command objects | |
| ## Problem | |
| When a command is registered under an explicit name, the group exposes that | |
| alias but the command object may still report its original public name. | |
| ## Desired behavior | |
| Update a command object's public name to match the explicit API name used during | |
| registration. | |
| ## Constraints | |
| Only explicit registration aliases should trigger the rename. Commands added | |
| without an alias should preserve their existing names. | |
| ## Success criteria | |
| After registering a command with an explicit alias, inspecting the command's | |
| public name returns the alias. | |
| ","# Task B: Reject duplicate public command names | |
| ## Problem | |
| A group can become ambiguous if two distinct command objects expose the same | |
| public command name. | |
| ## Desired behavior | |
| Reject registration of a distinct command object when its public command name is | |
| already registered on the same group. | |
| ## Constraints | |
| Re-registering the same command object should not be treated as a distinct-name | |
| collision unless existing Click behavior already rejects it. | |
| ## Success criteria | |
| Attempting to add two different command objects with the same public name raises | |
| a registration error. | |
| ","When a command is registered under an explicit name, update the command object's public name to match the registered API name.",Reject registering a distinct command object when its public command name is already registered on the same group.,"diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..e2a68f7 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1785,6 +1785,9 @@ class Group(Command): | |
| name = name or cmd.name | |
| if name is None: | |
| raise TypeError(""Command has no name."") | |
| + if cmd.name != name: | |
| + cmd.name = name | |
| + | |
| _check_nested_chain(self, name, cmd, register=True) | |
| self.commands[name] = cmd | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..11cec1e 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1789,2 +1789,8 @@ class Group(Command): | |
| self.commands[name] = cmd | |
| + if ( | |
| + cmd.name is not None | |
| + and cmd.name in self.commands | |
| + and self.commands[cmd.name] is not cmd | |
| + ): | |
| + raise TypeError(f""Command name {cmd.name!r} is already registered."") | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..8f929cc 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1785,8 +1785,17 @@ class Group(Command): | |
| name = name or cmd.name | |
| if name is None: | |
| raise TypeError(""Command has no name."") | |
| + if cmd.name != name: | |
| + cmd.name = name | |
| + | |
| _check_nested_chain(self, name, cmd, register=True) | |
| self.commands[name] = cmd | |
| + if ( | |
| + cmd.name is not None | |
| + and cmd.name in self.commands | |
| + and self.commands[cmd.name] is not cmd | |
| + ): | |
| + raise TypeError(f""Command name {cmd.name!r} is already registered."") | |
| @t.overload | |
| def command(self, __func: t.Callable[..., t.Any]) -> Command: ... | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import click | |
| def test_explicit_registration_name_updates_command_name(): | |
| cli = click.Group(""cli"") | |
| cmd = click.Command(""internal"") | |
| cli.add_command(cmd, ""public"") | |
| assert cmd.name == ""public"" | |
| assert cli.commands[""public""] is cmd | |
| ","import pytest | |
| import click | |
| def test_distinct_command_with_duplicate_public_name_is_rejected(): | |
| cli = click.Group(""cli"") | |
| cli.add_command(click.Command(""sync"")) | |
| with pytest.raises(TypeError, match=""already registered""): | |
| cli.add_command(click.Command(""sync""), ""sync-alias"") | |
| ","import pytest | |
| import click | |
| def test_alias_name_sync_does_not_bypass_duplicate_command_name_check(): | |
| cli = click.Group(""cli"") | |
| cli.add_command(click.Command(""sync"")) | |
| with pytest.raises(TypeError, match=""already registered""): | |
| cli.add_command(click.Command(""sync""), ""sync-alias"") | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A mutates a command object's public name to the explicit registration alias. Patch B rejects duplicate public command names after registration. Together, Patch A changes the name before Patch B checks for duplicates, allowing a duplicate original command name to bypass the new API-contract check.",Third seed instance. This demonstrates an API-contract conflict in Click command registration rather than option precedence or command lookup behavior.,instances/click__003 | |
| click__004,https://github.com/pallets/click,2c8cd3ac958a7eb316d67f2d316c27086c4c0369,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Unique command-prefix lookup | |
| ## Problem | |
| Long command names are inconvenient to type, and some CLIs allow users to invoke | |
| a command by an unambiguous prefix. | |
| ## Desired behavior | |
| Allow command lookup to resolve a command-name prefix when it uniquely matches a | |
| registered command. | |
| ## Constraints | |
| Ambiguous prefixes must not resolve silently. Exact command names should keep | |
| their current behavior. | |
| ## Success criteria | |
| If only `status` matches the prefix `sta`, invoking `sta` runs `status`; if more | |
| than one command matches, lookup remains unresolved or reports ambiguity. | |
| ","# Task B: Lowercase fallback for Click command lookup | |
| ## Problem | |
| Command invocations with accidental uppercase spelling fail even when the | |
| registered command has a clear lowercase equivalent. | |
| ## Desired behavior | |
| When exact lookup fails, retry lookup using the lowercase form of the invoked | |
| command name. | |
| ## Constraints | |
| Exact matches must still take priority. The fallback should not make command | |
| registration case-insensitive globally. | |
| ## Success criteria | |
| A group containing `status` can resolve `STATUS` to `status` when no exact | |
| `STATUS` command exists. | |
| ",Allow a command invocation to resolve a uniquely matching command-name prefix.,Allow command lookup to fall back to lowercase command names when an uppercase or mixed-case command invocation is not found exactly.,"diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..52d1cd2 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1938,7 +1938,21 @@ class Group(Command): | |
| """"""Given a context and a command name, this returns a :class:`Command` | |
| object if it exists or returns ``None``. | |
| """""" | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is not None: | |
| + return cmd | |
| + | |
| + matches = [ | |
| + command | |
| + for name, command in self.commands.items() | |
| + if name.startswith(cmd_name) | |
| + ] | |
| + | |
| + if len(matches) == 1: | |
| + return matches[0] | |
| + | |
| + return None | |
| def list_commands(self, ctx: Context) -> list[str]: | |
| """"""Returns a list of subcommand names in the order they should appear."""""" | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..cb1467c 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -2077,6 +2077,13 @@ class Group(Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| # If we don't find the command we want to show an error message | |
| # to the user that it was not provided. However, there is | |
| # something else we should do: if the first argument looks like | |
| ","diff --git a/src/click/core.py b/src/click/core.py | |
| index de129ec..6d9c664 100644 | |
| --- a/src/click/core.py | |
| +++ b/src/click/core.py | |
| @@ -1938,7 +1938,21 @@ class Group(Command): | |
| """"""Given a context and a command name, this returns a :class:`Command` | |
| object if it exists or returns ``None``. | |
| """""" | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is not None: | |
| + return cmd | |
| + | |
| + matches = [ | |
| + command | |
| + for name, command in self.commands.items() | |
| + if name.startswith(cmd_name) | |
| + ] | |
| + | |
| + if len(matches) == 1: | |
| + return matches[0] | |
| + | |
| + return None | |
| def list_commands(self, ctx: Context) -> list[str]: | |
| """"""Returns a list of subcommand names in the order they should appear."""""" | |
| @@ -2077,6 +2091,13 @@ class Group(Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| # If we don't find the command we want to show an error message | |
| # to the user that it was not provided. However, there is | |
| # something else we should do: if the first argument looks like | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import click | |
| from click.testing import CliRunner | |
| def test_unique_prefix_invocation_resolves_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""status"") | |
| def status(): | |
| click.echo(""ok"") | |
| @cli.command(""stop"") | |
| def stop(): | |
| click.echo(""stop"") | |
| result = CliRunner().invoke(cli, [""sta""]) | |
| assert result.output == ""ok\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_uppercase_invocation_resolves_lowercase_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""status"") | |
| def status(): | |
| click.echo(""ok"") | |
| result = CliRunner().invoke(cli, [""STATUS""]) | |
| assert result.output == ""ok\n"" | |
| ","import click | |
| from click.testing import CliRunner | |
| def test_uppercase_prefix_does_not_transitively_resolve_command(): | |
| @click.group() | |
| def cli(): | |
| pass | |
| @cli.command(""status"") | |
| def status(): | |
| click.echo(""ok"") | |
| result = CliRunner().invoke(cli, [""STA""]) | |
| assert result.exit_code != 0 | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A introduces unique-prefix command lookup. Patch B introduces lowercase fallback lookup. Together, an uppercase prefix such as STA is lowercased to sta and then resolved as a unique prefix for status, even though neither patch independently intended uppercase abbreviations.",Expansion seed instance. This is a controlled command-resolution conflict distinct from the underscore/dash aliasing interaction in click__002.,instances/click__004 | |
| typer__001,https://github.com/fastapi/typer,9a7b2e83f6b62c750d6026b0de9ebf2026a8b8fa,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Underscore aliases for dashed Typer commands | |
| ## Problem | |
| Typer command names often use dashes, while programmatic callers and scripts may | |
| produce underscores. | |
| ## Desired behavior | |
| Allow `TyperGroup` command lookup to treat underscores in the invoked command | |
| name as aliases for dashes in registered command names. | |
| ## Constraints | |
| Exact command lookup must remain unchanged. The alias should be a fallback and | |
| should not alter help output or registered command names. | |
| ## Success criteria | |
| A Typer command registered as `foo-bar` can be invoked as `foo_bar` when no | |
| exact `foo_bar` command exists. | |
| ","# Task B: Lowercase fallback for Typer command lookup | |
| ## Problem | |
| Users sometimes invoke Typer commands with uppercase or mixed-case spelling even | |
| when the intended command is registered in lowercase. | |
| ## Desired behavior | |
| Allow `TyperGroup` lookup to fall back to lowercase command names after exact | |
| lookup fails. | |
| ## Constraints | |
| Exact matches should still win. The fallback should not change registration | |
| names or help text. | |
| ## Success criteria | |
| A Typer app containing `status` can resolve an invocation of `STATUS` to the | |
| registered `status` command. | |
| ",Allow TyperGroup command lookup to treat underscores in an invoked command name as aliases for dashes in registered command names.,Allow TyperGroup command lookup to fall back to lowercase command names when a mixed-case or uppercase command invocation is not found exactly.,"diff --git a/typer/core.py b/typer/core.py | |
| index 1bfc399..1ef0610 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1048,7 +1048,12 @@ class TyperGroup(_click.Command): | |
| self.commands[name] = cmd | |
| def get_command(self, ctx: _click.Context, cmd_name: str) -> _click.Command | None: | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is None: | |
| + cmd = self.commands.get(cmd_name.replace(""_"", ""-"")) | |
| + | |
| + return cmd | |
| def collect_usage_pieces(self, ctx: _click.Context) -> list[str]: | |
| rv = super().collect_usage_pieces(ctx) | |
| ","diff --git a/typer/core.py b/typer/core.py | |
| index 1bfc399..554d213 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1168,6 +1168,13 @@ class TyperGroup(_click.Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| if cmd is None and not ctx.resilient_parsing: | |
| if _split_opt(cmd_name)[0]: | |
| self.parse_args(ctx, args) | |
| ","diff --git a/typer/core.py b/typer/core.py | |
| index 1bfc399..777e0ab 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1048,7 +1048,12 @@ class TyperGroup(_click.Command): | |
| self.commands[name] = cmd | |
| def get_command(self, ctx: _click.Context, cmd_name: str) -> _click.Command | None: | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is None: | |
| + cmd = self.commands.get(cmd_name.replace(""_"", ""-"")) | |
| + | |
| + return cmd | |
| def collect_usage_pieces(self, ctx: _click.Context) -> list[str]: | |
| rv = super().collect_usage_pieces(ctx) | |
| @@ -1168,6 +1173,13 @@ class TyperGroup(_click.Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| if cmd is None and not ctx.resilient_parsing: | |
| if _split_opt(cmd_name)[0]: | |
| self.parse_args(ctx, args) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import typer | |
| from typer.testing import CliRunner | |
| def test_underscore_invocation_resolves_dashed_command(): | |
| app = typer.Typer() | |
| @app.command(""foo-bar"") | |
| def foo_bar(): | |
| typer.echo(""dash"") | |
| @app.command(""other"") | |
| def other(): | |
| typer.echo(""other"") | |
| result = CliRunner().invoke(app, [""foo_bar""]) | |
| assert result.output == ""dash\n"" | |
| ","import typer | |
| from typer.testing import CliRunner | |
| def test_uppercase_invocation_resolves_lowercase_command(): | |
| app = typer.Typer() | |
| @app.command(""status"") | |
| def status(): | |
| typer.echo(""ok"") | |
| @app.command(""other"") | |
| def other(): | |
| typer.echo(""other"") | |
| result = CliRunner().invoke(app, [""STATUS""]) | |
| assert result.output == ""ok\n"" | |
| ","import typer | |
| from typer.testing import CliRunner | |
| def test_uppercase_underscore_does_not_transitively_resolve_dashed_command(): | |
| app = typer.Typer() | |
| @app.command(""foo-bar"") | |
| def foo_bar(): | |
| typer.echo(""dash"") | |
| @app.command(""other"") | |
| def other(): | |
| typer.echo(""other"") | |
| result = CliRunner().invoke(app, [""FOO_BAR""]) | |
| assert result.exit_code != 0 | |
| assert ""No such command"" in result.output | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A introduces underscore-to-dash command aliasing in TyperGroup. Patch B introduces case-insensitive fallback lookup. Together, they create an unintended transitive lookup where FOO_BAR resolves to foo-bar, even though neither patch independently admits that invocation form.",First non-Click seed instance. This demonstrates that the command-resolution interference pattern can appear in Typer's framework layer as well.,instances/typer__001 | |
| typer__002,https://github.com/fastapi/typer,9a7b2e83f6b62c750d6026b0de9ebf2026a8b8fa,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Unique-prefix Typer command lookup | |
| ## Problem | |
| Typer command names may be long, and users sometimes expect unambiguous | |
| abbreviations to work. | |
| ## Desired behavior | |
| Allow a Typer command invocation to resolve a uniquely matching command-name | |
| prefix. | |
| ## Constraints | |
| Ambiguous prefixes must not execute a command silently. Exact command names | |
| should preserve their current behavior. | |
| ## Success criteria | |
| If `status` is the only registered command beginning with `sta`, invoking `sta` | |
| resolves to `status`. | |
| ","# Task B: Lowercase fallback for Typer invocations | |
| ## Problem | |
| Case mistakes in command invocations are common, especially in scripts and | |
| documentation examples. | |
| ## Desired behavior | |
| When exact Typer command lookup fails, retry lookup using the lowercase invoked | |
| name. | |
| ## Constraints | |
| The fallback should not rewrite registered command names or affect exact | |
| case-sensitive matches. | |
| ## Success criteria | |
| A command registered as `status` can be invoked as `STATUS` when no exact | |
| uppercase command exists. | |
| ",Allow a Typer command invocation to resolve a uniquely matching command-name prefix.,Allow Typer command lookup to fall back to lowercase command names when an uppercase or mixed-case command invocation is not found exactly.,"diff --git a/typer/core.py b/typer/core.py | |
| index 51cd733..e8d09d3 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1048,7 +1048,21 @@ class TyperGroup(_click.Command): | |
| self.commands[name] = cmd | |
| def get_command(self, ctx: _click.Context, cmd_name: str) -> _click.Command | None: | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is not None: | |
| + return cmd | |
| + | |
| + matches = [ | |
| + command | |
| + for name, command in self.commands.items() | |
| + if name.startswith(cmd_name) | |
| + ] | |
| + | |
| + if len(matches) == 1: | |
| + return matches[0] | |
| + | |
| + return None | |
| def collect_usage_pieces(self, ctx: _click.Context) -> list[str]: | |
| rv = super().collect_usage_pieces(ctx) | |
| ","diff --git a/typer/core.py b/typer/core.py | |
| index 51cd733..a23b195 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1168,6 +1168,13 @@ class TyperGroup(_click.Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| if cmd is None and not ctx.resilient_parsing: | |
| if _split_opt(cmd_name)[0]: | |
| self.parse_args(ctx, args) | |
| ","diff --git a/typer/core.py b/typer/core.py | |
| index 1bfc399..30d71a0 100644 | |
| --- a/typer/core.py | |
| +++ b/typer/core.py | |
| @@ -1048,7 +1048,21 @@ class TyperGroup(_click.Command): | |
| self.commands[name] = cmd | |
| def get_command(self, ctx: _click.Context, cmd_name: str) -> _click.Command | None: | |
| - return self.commands.get(cmd_name) | |
| + cmd = self.commands.get(cmd_name) | |
| + | |
| + if cmd is not None: | |
| + return cmd | |
| + | |
| + matches = [ | |
| + command | |
| + for name, command in self.commands.items() | |
| + if name.startswith(cmd_name) | |
| + ] | |
| + | |
| + if len(matches) == 1: | |
| + return matches[0] | |
| + | |
| + return None | |
| def collect_usage_pieces(self, ctx: _click.Context) -> list[str]: | |
| rv = super().collect_usage_pieces(ctx) | |
| @@ -1168,6 +1182,13 @@ class TyperGroup(_click.Command): | |
| cmd_name = ctx.token_normalize_func(cmd_name) | |
| cmd = self.get_command(ctx, cmd_name) | |
| + if cmd is None: | |
| + lower_cmd_name = cmd_name.lower() | |
| + | |
| + if lower_cmd_name != cmd_name: | |
| + cmd_name = lower_cmd_name | |
| + cmd = self.get_command(ctx, cmd_name) | |
| + | |
| if cmd is None and not ctx.resilient_parsing: | |
| if _split_opt(cmd_name)[0]: | |
| self.parse_args(ctx, args) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import typer | |
| from typer.testing import CliRunner | |
| def test_unique_prefix_invocation_resolves_command(): | |
| app = typer.Typer() | |
| @app.command(""status"") | |
| def status(): | |
| typer.echo(""ok"") | |
| @app.command(""stop"") | |
| def stop(): | |
| typer.echo(""stop"") | |
| result = CliRunner().invoke(app, [""sta""]) | |
| assert result.output == ""ok\n"" | |
| ","import typer | |
| from typer.testing import CliRunner | |
| def test_uppercase_invocation_resolves_lowercase_command(): | |
| app = typer.Typer() | |
| @app.command(""status"") | |
| def status(): | |
| typer.echo(""ok"") | |
| @app.command(""other"") | |
| def other(): | |
| typer.echo(""other"") | |
| result = CliRunner().invoke(app, [""STATUS""]) | |
| assert result.output == ""ok\n"" | |
| ","import typer | |
| from typer.testing import CliRunner | |
| def test_uppercase_prefix_does_not_transitively_resolve_command(): | |
| app = typer.Typer() | |
| @app.command(""status"") | |
| def status(): | |
| typer.echo(""ok"") | |
| @app.command(""other"") | |
| def other(): | |
| typer.echo(""other"") | |
| result = CliRunner().invoke(app, [""STA""]) | |
| assert result.exit_code != 0 | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A introduces unique-prefix command lookup in TyperGroup. Patch B introduces lowercase fallback lookup. Together, an uppercase prefix such as STA is lowercased and then resolved as a unique prefix for status, creating an unintended command invocation path.",Expansion seed instance. This mirrors the command-resolution interaction in Typer's custom Click-compatible group implementation.,instances/typer__002 | |
| commander__001,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Unique-prefix Commander subcommands | |
| ## Problem | |
| Commander subcommands can have long names, and users may expect an | |
| unambiguous abbreviation to resolve to the intended command. | |
| ## Desired behavior | |
| Allow subcommand lookup to resolve a command-name prefix when exactly one | |
| registered subcommand matches that prefix. | |
| ## Constraints | |
| Ambiguous prefixes must not execute a command silently. Exact subcommand names | |
| should keep their current behavior. | |
| ## Success criteria | |
| If `status` is the only subcommand beginning with `sta`, invoking `sta` runs the | |
| `status` subcommand. | |
| ","# Task B: Lowercase fallback for Commander subcommands | |
| ## Problem | |
| Users may type Commander subcommands with uppercase or mixed-case spelling even | |
| when the registered subcommand is lowercase. | |
| ## Desired behavior | |
| When exact subcommand dispatch fails, retry lookup with the lowercase invoked | |
| subcommand name. | |
| ## Constraints | |
| Exact matches should still take priority. The fallback should not change | |
| registered command names or help output. | |
| ## Success criteria | |
| A program containing a `status` subcommand can dispatch an invocation of | |
| `STATUS` to `status`. | |
| ",Allow a Commander subcommand invocation to resolve a uniquely matching command-name prefix.,Allow Commander subcommand dispatch to fall back to lowercase command names when an uppercase or mixed-case invocation is not found exactly.,"diff --git a/lib/command.js b/lib/command.js | |
| index e79a5ad..885f7d3 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -1660,10 +1660,20 @@ export class Command extends EventEmitter { | |
| * @return {Command | undefined} | |
| */ | |
| _findCommand(name) { | |
| if (!name) return undefined; | |
| - return this.commands.find( | |
| + const exact = this.commands.find( | |
| (cmd) => cmd._name === name || cmd._aliases.includes(name), | |
| ); | |
| + if (exact) return exact; | |
| + | |
| + const matches = this.commands.filter( | |
| + (cmd) => | |
| + cmd._name.startsWith(name) || | |
| + cmd._aliases.some((alias) => alias.startsWith(name)), | |
| + ); | |
| + if (matches.length === 1) return matches[0]; | |
| + | |
| + return undefined; | |
| } | |
| /** | |
| * Return an option matching `arg` if any. | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index e79a5ad..3f3cc61 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -1567,6 +1567,14 @@ export class Command extends EventEmitter { | |
| unknown = parsed.unknown; | |
| this.args = operands.concat(unknown); | |
| + if (operands.length && !this._findCommand(operands[0])) { | |
| + const lowerCommandName = operands[0].toLowerCase(); | |
| + | |
| + if (lowerCommandName !== operands[0] && this._findCommand(lowerCommandName)) { | |
| + operands[0] = lowerCommandName; | |
| + } | |
| + } | |
| + | |
| if (operands && this._findCommand(operands[0])) { | |
| return this._dispatchSubcommand(operands[0], operands.slice(1), unknown); | |
| } | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..1bb74e3 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -1567,6 +1567,14 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| unknown = parsed.unknown; | |
| this.args = operands.concat(unknown); | |
| + if (operands.length && !this._findCommand(operands[0])) { | |
| + const lowerCommandName = operands[0].toLowerCase(); | |
| + | |
| + if (lowerCommandName !== operands[0] && this._findCommand(lowerCommandName)) { | |
| + operands[0] = lowerCommandName; | |
| + } | |
| + } | |
| + | |
| if (operands && this._findCommand(operands[0])) { | |
| return this._dispatchSubcommand(operands[0], operands.slice(1), unknown); | |
| } | |
| @@ -1660,9 +1668,19 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| */ | |
| _findCommand(name) { | |
| if (!name) return undefined; | |
| - return this.commands.find( | |
| + const exact = this.commands.find( | |
| (cmd) => cmd._name === name || cmd._aliases.includes(name), | |
| ); | |
| + if (exact) return exact; | |
| + | |
| + const matches = this.commands.filter( | |
| + (cmd) => | |
| + cmd._name.startsWith(name) || | |
| + cmd._aliases.some((alias) => alias.startsWith(name)), | |
| + ); | |
| + if (matches.length === 1) return matches[0]; | |
| + | |
| + return undefined; | |
| } | |
| /** | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('unique prefix invocation resolves subcommand', () => { | |
| const program = new Command(); | |
| let called = ''; | |
| program.exitOverride(); | |
| program.configureOutput({ writeOut: () => {}, writeErr: () => {} }); | |
| program.command('status').action(() => { | |
| called = 'status'; | |
| }); | |
| program.command('stop').action(() => { | |
| called = 'stop'; | |
| }); | |
| program.parse(['node', 'test', 'sta']); | |
| assert.equal(called, 'status'); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('uppercase invocation resolves lowercase subcommand', () => { | |
| const program = new Command(); | |
| let called = ''; | |
| program.exitOverride(); | |
| program.configureOutput({ writeOut: () => {}, writeErr: () => {} }); | |
| program.command('status').action(() => { | |
| called = 'status'; | |
| }); | |
| program.command('other').action(() => { | |
| called = 'other'; | |
| }); | |
| program.parse(['node', 'test', 'STATUS']); | |
| assert.equal(called, 'status'); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('uppercase prefix does not transitively resolve subcommand', () => { | |
| const program = new Command(); | |
| let called = ''; | |
| program.exitOverride(); | |
| program.configureOutput({ writeOut: () => {}, writeErr: () => {} }); | |
| program.command('status').action(() => { | |
| called = 'status'; | |
| }); | |
| program.command('other').action(() => { | |
| called = 'other'; | |
| }); | |
| assert.throws(() => { | |
| program.parse(['node', 'test', 'STA']); | |
| }); | |
| assert.equal(called, ''); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A introduces unique-prefix subcommand lookup. Patch B introduces lowercase fallback before dispatch. Together, an uppercase prefix such as STA is lowercased to sta and then resolved as a unique prefix for status, admitting a command spelling neither patch independently intended.",First JavaScript seed instance. The oracle uses Node's built-in node:test runner and imports Commander from the local repository checkout.,instances/commander__001 | |
| commander__002,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,configuration,fail,easy,researcher_constructed,reproduced,"# Task A: False-like environment values for booleans | |
| ## Problem | |
| Boolean options sourced from environment variables often receive string values | |
| such as `false`, `0`, or `no`, which should be interpreted as false rather than | |
| truthy strings. | |
| ## Desired behavior | |
| Treat common false-like environment values for boolean options as boolean | |
| `false`. | |
| ## Constraints | |
| The change should apply to boolean options loaded from environment values and | |
| should not alter parsing of non-boolean option values. | |
| ## Success criteria | |
| An environment variable such as `DEBUG=false` produces `debug: false` for a | |
| boolean option. | |
| ","# Task B: Implied option values override configuration sources | |
| ## Problem | |
| An option may imply another option value, and users expect that implication to | |
| take effect even when the implied option has a value from environment or config. | |
| ## Desired behavior | |
| Allow implied option values to override values derived from environment or | |
| configuration sources. | |
| ## Constraints | |
| Explicit user-supplied CLI values should still have the highest precedence. The | |
| change should only affect implied values competing with lower-priority sources. | |
| ## Success criteria | |
| When `--trace` implies `debug: true`, invoking `--trace` sets `debug` to true | |
| even if `debug` already has an environment-derived value. | |
| ",Treat common false-like environment values for boolean options as false.,Allow implied option values to override environment/config-derived values.,"diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..14f364a 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -1992,8 +1992,9 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]); | |
| } else { | |
| // boolean | |
| - // keep very simple, only care that envVar defined and not the value | |
| - this.emit(`optionEnv:${option.name()}`); | |
| + const envValue = process.env[option.envVar]; | |
| + const booleanValue = !/^(0|false|no)$/i.test(envValue); | |
| + this.setOptionValueWithSource(optionKey, booleanValue, 'env'); | |
| } | |
| } | |
| } | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..e8794d7 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -2010,7 +2010,9 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| const hasCustomOptionValue = (optionKey) => { | |
| return ( | |
| this.getOptionValue(optionKey) !== undefined && | |
| - !['default', 'implied'].includes(this.getOptionValueSource(optionKey)) | |
| + !['default', 'env', 'config', 'implied'].includes( | |
| + this.getOptionValueSource(optionKey), | |
| + ) | |
| ); | |
| }; | |
| this.options | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..e0cbae3 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -1992,8 +1992,9 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]); | |
| } else { | |
| // boolean | |
| - // keep very simple, only care that envVar defined and not the value | |
| - this.emit(`optionEnv:${option.name()}`); | |
| + const envValue = process.env[option.envVar]; | |
| + const booleanValue = !/^(0|false|no)$/i.test(envValue); | |
| + this.setOptionValueWithSource(optionKey, booleanValue, 'env'); | |
| } | |
| } | |
| } | |
| @@ -2010,7 +2011,9 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| const hasCustomOptionValue = (optionKey) => { | |
| return ( | |
| this.getOptionValue(optionKey) !== undefined && | |
| - !['default', 'implied'].includes(this.getOptionValueSource(optionKey)) | |
| + !['default', 'env', 'config', 'implied'].includes( | |
| + this.getOptionValueSource(optionKey), | |
| + ) | |
| ); | |
| }; | |
| this.options | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| function withEnv(name, value, fn) { | |
| const previous = process.env[name]; | |
| process.env[name] = value; | |
| try { | |
| fn(); | |
| } finally { | |
| if (previous === undefined) { | |
| delete process.env[name]; | |
| } else { | |
| process.env[name] = previous; | |
| } | |
| } | |
| } | |
| test('boolean env false is parsed as false', () => { | |
| withEnv('COMMANDER_DEBUG', 'false', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program.addOption(new Option('--debug').env('COMMANDER_DEBUG')); | |
| program.parse(['node', 'test']); | |
| assert.equal(program.opts().debug, false); | |
| assert.equal(program.getOptionValueSource('debug'), 'env'); | |
| }); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| function withEnv(name, value, fn) { | |
| const previous = process.env[name]; | |
| process.env[name] = value; | |
| try { | |
| fn(); | |
| } finally { | |
| if (previous === undefined) { | |
| delete process.env[name]; | |
| } else { | |
| process.env[name] = previous; | |
| } | |
| } | |
| } | |
| test('implied value can override env-derived configuration', () => { | |
| withEnv('COMMANDER_LOG', 'env.log', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program | |
| .addOption(new Option('--log <file>').env('COMMANDER_LOG')) | |
| .addOption(new Option('--trace').implies({ log: 'trace.log' })); | |
| program.parse(['node', 'test', '--trace']); | |
| assert.equal(program.opts().log, 'trace.log'); | |
| assert.equal(program.getOptionValueSource('log'), 'implied'); | |
| }); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| function withEnv(name, value, fn) { | |
| const previous = process.env[name]; | |
| process.env[name] = value; | |
| try { | |
| fn(); | |
| } finally { | |
| if (previous === undefined) { | |
| delete process.env[name]; | |
| } else { | |
| process.env[name] = previous; | |
| } | |
| } | |
| } | |
| test('explicit false boolean env value is not overwritten by implication', () => { | |
| withEnv('COMMANDER_DEBUG', 'false', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program | |
| .addOption(new Option('--debug').env('COMMANDER_DEBUG')) | |
| .addOption(new Option('--trace').implies({ debug: true })); | |
| program.parse(['node', 'test', '--trace']); | |
| assert.equal(program.opts().debug, false); | |
| assert.equal(program.getOptionValueSource('debug'), 'env'); | |
| }); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A turns DEBUG=false into an explicit env-derived false value. Patch B lets implied option values override env/config-derived values. Together, --trace can override DEBUG=false via an implied debug=true value, violating the intended configuration precedence contract.",Second Commander.js seed instance. This expands configuration-precedence coverage with a JavaScript-only example.,instances/commander__002 | |
| commander__003,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Flag spelling aliases for option conflicts | |
| ## Problem | |
| Commander option conflict declarations are easier to write with CLI flag | |
| spellings such as `--cache-dir`, but internally options are tracked by | |
| attribute names such as `cacheDir`. | |
| ## Desired behavior | |
| Allow `Option.conflicts()` to accept long flag spellings and normalize them to | |
| Commander option attribute names. | |
| ## Constraints | |
| Existing attribute-name inputs must continue to work. The change should only | |
| affect conflict declaration normalization. | |
| ## Success criteria | |
| Declaring a conflict with `--cache-dir` behaves the same as declaring it with | |
| `cacheDir`. | |
| ","# Task B: Flag spelling aliases for implied option values | |
| ## Problem | |
| Commander implication declarations are easier to read when they use CLI flag | |
| spellings, but implied values are applied using internal option attribute names. | |
| ## Desired behavior | |
| Allow `Option.implies()` to accept long flag spellings and normalize them when | |
| setting implied option values. | |
| ## Constraints | |
| Existing attribute-name inputs must continue to work. The change should not | |
| alter how users provide options on the command line. | |
| ## Success criteria | |
| An implication declared for `--cache-dir` sets the same option value as an | |
| implication declared for `cacheDir`. | |
| ","Allow Option.conflicts() to accept long option flag spellings, such as --cache-dir, as aliases for Commander option attribute names, such as cacheDir.","Allow Option.implies() to accept long option flag spellings, such as --cache-dir, and normalize them to Commander option attribute names when setting implied option values.","diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..caa8325 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -80,7 +80,16 @@ export class Option { | |
| */ | |
| conflicts(names) { | |
| - this.conflictsWith = this.conflictsWith.concat(names); | |
| + const normaliseName = (name) => { | |
| + if (name.startsWith('--no-')) { | |
| + return camelcase(name.slice(5)); | |
| + } | |
| + if (name.startsWith('--')) { | |
| + return camelcase(name.slice(2)); | |
| + } | |
| + return name; | |
| + }; | |
| + this.conflictsWith = this.conflictsWith.concat(names).map(normaliseName); | |
| return this; | |
| } | |
| ","diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..6d7754d 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -103,6 +103,12 @@ export class Option { | |
| // string is not documented, but easy mistake and we can do what user probably intended. | |
| newImplied = { [impliedOptionValues]: true }; | |
| } | |
| + newImplied = Object.fromEntries( | |
| + Object.entries(newImplied).map(([key, value]) => [ | |
| + key.startsWith('--') ? camelcase(key.replace(/^--(?:no-)?/, '')) : key, | |
| + value, | |
| + ]), | |
| + ); | |
| this.implied = Object.assign(this.implied || {}, newImplied); | |
| return this; | |
| } | |
| ","diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..9fbe5f2 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -80,7 +80,16 @@ export class Option { | |
| */ | |
| conflicts(names) { | |
| - this.conflictsWith = this.conflictsWith.concat(names); | |
| + const normaliseName = (name) => { | |
| + if (name.startsWith('--no-')) { | |
| + return camelcase(name.slice(5)); | |
| + } | |
| + if (name.startsWith('--')) { | |
| + return camelcase(name.slice(2)); | |
| + } | |
| + return name; | |
| + }; | |
| + this.conflictsWith = this.conflictsWith.concat(names).map(normaliseName); | |
| return this; | |
| } | |
| @@ -103,6 +112,12 @@ export class Option { | |
| // string is not documented, but easy mistake and we can do what user probably intended. | |
| newImplied = { [impliedOptionValues]: true }; | |
| } | |
| + newImplied = Object.fromEntries( | |
| + Object.entries(newImplied).map(([key, value]) => [ | |
| + key.startsWith('--') ? camelcase(key.replace(/^--(?:no-)?/, '')) : key, | |
| + value, | |
| + ]), | |
| + ); | |
| this.implied = Object.assign(this.implied || {}, newImplied); | |
| return this; | |
| } | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('conflicts accepts long option flag spelling', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program | |
| .addOption(new Option('--cache-dir <path>')) | |
| .addOption(new Option('--offline').conflicts('--cache-dir')); | |
| assert.throws( | |
| () => program.parse(['node', 'test', '--offline', '--cache-dir', './cache']), | |
| { code: 'commander.conflictingOption' }, | |
| ); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('implies accepts long option flag spelling', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program | |
| .addOption(new Option('--cache-dir <path>')) | |
| .addOption(new Option('--offline').implies({ '--cache-dir': './cache' })); | |
| program.parse(['node', 'test', '--offline']); | |
| assert.equal(program.opts().cacheDir, './cache'); | |
| assert.equal(program.getOptionValueSource('cacheDir'), 'implied'); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('self-implied option value does not trigger a user-facing conflict', () => { | |
| const program = new Command(); | |
| program.exitOverride(); | |
| program | |
| .addOption(new Option('--cache-dir <path>')) | |
| .addOption( | |
| new Option('--offline') | |
| .conflicts('--cache-dir') | |
| .implies({ '--cache-dir': './cache' }), | |
| ); | |
| program.parse(['node', 'test', '--offline']); | |
| assert.equal(program.opts().cacheDir, './cache'); | |
| assert.equal(program.getOptionValueSource('cacheDir'), 'implied'); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A normalizes flag spellings in conflicts(). Patch B normalizes flag spellings in implies(). Together, an option that both conflicts with and implies the same flag spelling converts the implied value into the canonical option key, so Commander reports a user-facing conflict even though the user only supplied the implying option.",Third JavaScript seed instance. It captures an API-contract interaction between two helper APIs that each accept user-facing long flag spellings.,instances/commander__003 | |
| commander__004,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Clear defaults when making prepared arguments optional | |
| ## Problem | |
| A prepared `Argument` can be converted from required to optional after it has | |
| already been given a default value, leaving stale fallback state attached to the | |
| argument. | |
| ## Desired behavior | |
| Update `Argument.argOptional()` so converting an argument to optional clears any | |
| existing default value. | |
| ## Constraints | |
| The method should still mark the argument optional and return the argument for | |
| chaining. Other argument metadata should remain unchanged. | |
| ## Success criteria | |
| Calling `new Argument(""<file>"").default(""fallback"").argOptional()` produces an | |
| optional argument whose default value is unset. | |
| ","# Task B: Accept prepared required arguments with defaults | |
| ## Problem | |
| `Command.addArgument()` rejects a prepared required `Argument` that has a | |
| default value, even though applications may want to interpret that default as a | |
| fallback for omitted input. | |
| ## Desired behavior | |
| Allow `Command.addArgument()` to treat such prepared arguments as optional | |
| fallback arguments instead of throwing during registration. | |
| ## Constraints | |
| The configured default should still be used when the argument is omitted. | |
| Argument registration should continue to reject unrelated invalid argument | |
| shapes. | |
| ## Success criteria | |
| Adding `new Argument(""<file>"").default(""fallback"")` succeeds, and parsing with | |
| no positional value passes `""fallback""` to the action. | |
| ",Allow Argument.argOptional() to clear stale default values when converting required arguments into optional arguments.,Allow Command.addArgument() to treat prepared required arguments with defaults as optional fallback arguments.,"diff --git a/lib/argument.js b/lib/argument.js | |
| index 6da521d..a168149 100644 | |
| --- a/lib/argument.js | |
| +++ b/lib/argument.js | |
| @@ -126,10 +126,11 @@ export class Argument { | |
| * | |
| * @returns {Argument} | |
| */ | |
| argOptional() { | |
| this.required = false; | |
| + this.defaultValue = undefined; | |
| return this; | |
| } | |
| } | |
| /** | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..36d458e 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -383,13 +383,11 @@ export class Command extends EventEmitter { | |
| if ( | |
| argument.required && | |
| argument.defaultValue !== undefined && | |
| argument.parseArg === undefined | |
| ) { | |
| - throw new Error( | |
| - `a default value for a required argument is never used: '${argument.name()}'`, | |
| - ); | |
| + argument.argOptional(); | |
| } | |
| this.registeredArguments.push(argument); | |
| return this; | |
| } | |
| ","diff --git a/lib/argument.js b/lib/argument.js | |
| index 6da521d..a168149 100644 | |
| --- a/lib/argument.js | |
| +++ b/lib/argument.js | |
| @@ -126,10 +126,11 @@ export class Argument { | |
| * | |
| * @returns {Argument} | |
| */ | |
| argOptional() { | |
| this.required = false; | |
| + this.defaultValue = undefined; | |
| return this; | |
| } | |
| } | |
| /** | |
| diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..36d458e 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -383,13 +383,11 @@ export class Command extends EventEmitter { | |
| if ( | |
| argument.required && | |
| argument.defaultValue !== undefined && | |
| argument.parseArg === undefined | |
| ) { | |
| - throw new Error( | |
| - `a default value for a required argument is never used: '${argument.name()}'`, | |
| - ); | |
| + argument.argOptional(); | |
| } | |
| this.registeredArguments.push(argument); | |
| return this; | |
| } | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Argument } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('argOptional clears default values when changing required arguments', () => { | |
| const arg = new Argument('<file>').default('fallback').argOptional(); | |
| assert.equal(arg.required, false); | |
| assert.equal(arg.defaultValue, undefined); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Argument, Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('required argument default is treated as optional fallback', () => { | |
| const program = new Command(); | |
| let seen; | |
| program.addArgument(new Argument('<file>').default('fallback')).action((file) => { | |
| seen = file; | |
| }); | |
| program.parse(['node', 'test']); | |
| assert.equal(seen, 'fallback'); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Argument, Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('required argument defaults survive the optionalization path', () => { | |
| const program = new Command(); | |
| let seen; | |
| program.addArgument(new Argument('<file>').default('fallback')).action((file) => { | |
| seen = file; | |
| }); | |
| program.parse(['node', 'test']); | |
| assert.equal(seen, 'fallback'); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes argOptional() so it clears default values. Patch B starts using argOptional() to reinterpret required arguments with defaults as optional fallback arguments. Together, the fallback value is silently discarded, so a missing argument resolves to undefined instead of the configured default.",Commander.js API-contract interaction around default-bearing positional arguments and helper reuse.,instances/commander__004 | |
| commander__005,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Classify negated options as boolean options | |
| ## Problem | |
| Negated options such as `--no-cache` behave like boolean flags but may not be | |
| reported as boolean options by generic option-inspection code. | |
| ## Desired behavior | |
| Update boolean option classification so negated options are treated as boolean | |
| options. | |
| ## Constraints | |
| Required and optional value-taking options should not be classified as plain | |
| boolean options. Runtime behavior of `--no-*` flags should remain unchanged. | |
| ## Success criteria | |
| `new Option(""--no-cache"").isBoolean()` returns true, and parsing `--no-cache` | |
| still sets `cache` to false. | |
| ","# Task B: Simplify missing option value resolution | |
| ## Problem | |
| Commander has multiple branches for filling in missing option values, including | |
| boolean, optional, and negated options. | |
| ## Desired behavior | |
| Resolve boolean and optional options before falling through to the dedicated | |
| negated-option value branch. | |
| ## Constraints | |
| The public behavior of negated options must remain unchanged. Passing `--no-*` | |
| without an explicit value should still produce false. | |
| ## Success criteria | |
| A program with `--no-cache` still reports `cache: false` after parsing | |
| `--no-cache`. | |
| ",Classify negated options as boolean options so generic option-inspection code treats boolean flags uniformly.,Resolve boolean and optional option values before falling through to the dedicated negated-option value branch.,"diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..d80d923 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -252,11 +252,11 @@ export class Option { | |
| * @return {boolean} | |
| * @package | |
| */ | |
| isBoolean() { | |
| - return !this.required && !this.optional && !this.negate; | |
| + return !this.required && !this.optional; | |
| } | |
| } | |
| /** | |
| * This class is to make it easier to work with dual options, without changing the existing | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..6d5ff84 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -695,14 +695,14 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| val = option._collectValue(val, oldValue); | |
| } | |
| // Fill-in appropriate missing values. Long winded but easy to follow. | |
| if (val == null) { | |
| - if (option.negate) { | |
| - val = false; | |
| - } else if (option.isBoolean() || option.optional) { | |
| + if (option.isBoolean() || option.optional) { | |
| val = true; | |
| + } else if (option.negate) { | |
| + val = false; | |
| } else { | |
| val = ''; // not normal, parseArg might have failed or be a mock function for testing | |
| } | |
| } | |
| this.setOptionValueWithSource(name, val, valueSource); | |
| ","diff --git a/lib/command.js b/lib/command.js | |
| index 9a3d03e..6d5ff84 100644 | |
| --- a/lib/command.js | |
| +++ b/lib/command.js | |
| @@ -695,14 +695,14 @@ Expecting one of '${allowedValues.join(""', '"")}'`); | |
| val = option._collectValue(val, oldValue); | |
| } | |
| // Fill-in appropriate missing values. Long winded but easy to follow. | |
| if (val == null) { | |
| - if (option.negate) { | |
| - val = false; | |
| - } else if (option.isBoolean() || option.optional) { | |
| + if (option.isBoolean() || option.optional) { | |
| val = true; | |
| + } else if (option.negate) { | |
| + val = false; | |
| } else { | |
| val = ''; // not normal, parseArg might have failed or be a mock function for testing | |
| } | |
| } | |
| this.setOptionValueWithSource(name, val, valueSource); | |
| }; | |
| diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..d80d923 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -252,11 +252,11 @@ export class Option { | |
| * @return {boolean} | |
| * @package | |
| */ | |
| isBoolean() { | |
| - return !this.required && !this.optional && !this.negate; | |
| + return !this.required && !this.optional; | |
| } | |
| } | |
| /** | |
| * This class is to make it easier to work with dual options, without changing the existing | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('negated options are classified as boolean options', () => { | |
| assert.equal(new Option('--no-cache').isBoolean(), true); | |
| const program = new Command(); | |
| program.option('--no-cache'); | |
| program.parse(['node', 'test', '--no-cache']); | |
| assert.equal(program.opts().cache, false); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('negated options still resolve to false without an explicit value', () => { | |
| const program = new Command(); | |
| program.option('--no-cache'); | |
| program.parse(['node', 'test', '--no-cache']); | |
| assert.equal(program.opts().cache, false); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Command } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('negated options still resolve to false after boolean classification changes', () => { | |
| const program = new Command(); | |
| program.option('--no-cache'); | |
| program.parse(['node', 'test', '--no-cache']); | |
| assert.equal(program.opts().cache, false); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A broadens Option.isBoolean() to include negated options. Patch B checks isBoolean() before the negate-specific branch. Together, --no-cache is interpreted as a regular boolean flag and becomes true instead of false.",Commander.js behavioral interaction between option classification and value-resolution branch ordering.,instances/commander__005 | |
| commander_control__001,https://github.com/tj/commander.js,ba6d13ddb4243e5913367734f8c159089ffe7834,JavaScript,control,pass,easy,researcher_constructed,reproduced,"# Patch A task | |
| Add an introspection helper for positional arguments. | |
| Users who build higher-level tooling around Commander need to know whether an | |
| `Argument` instance is required without parsing the decorated usage string. Add | |
| an `isRequired()` method to `Argument` that returns the argument's existing | |
| required/optional state. | |
| Constraints: | |
| - Do not change parsing behavior. | |
| - Do not change argument construction or help output. | |
| - Preserve the existing `argOptional()` behavior. | |
| ","# Patch B task | |
| Add an introspection helper for negated options. | |
| Users who inspect command schemas need to distinguish `--no-*` options from | |
| ordinary boolean options without reaching into private fields. Add an | |
| `isNegated()` method to `Option` that returns whether the option was declared as | |
| a negated option. | |
| Constraints: | |
| - Do not change option parsing behavior. | |
| - Do not change how boolean options are classified. | |
| - Preserve existing negated option semantics. | |
| ",Add Argument.isRequired() so tooling can inspect whether a positional argument is required.,Add Option.isNegated() so tooling can inspect whether an option was declared as --no-*.,"diff --git a/lib/argument.js b/lib/argument.js | |
| index 6da521d..ded0d68 100644 | |
| --- a/lib/argument.js | |
| +++ b/lib/argument.js | |
| @@ -128,10 +128,19 @@ export class Argument { | |
| */ | |
| argOptional() { | |
| this.required = false; | |
| return this; | |
| } | |
| + | |
| + /** | |
| + * Return whether argument is required. | |
| + * | |
| + * @returns {boolean} | |
| + */ | |
| + isRequired() { | |
| + return this.required; | |
| + } | |
| } | |
| /** | |
| * Takes an argument and returns its human readable equivalent for help usage. | |
| * | |
| ","diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..d7ed57f 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -254,10 +254,21 @@ export class Option { | |
| */ | |
| isBoolean() { | |
| return !this.required && !this.optional && !this.negate; | |
| } | |
| + | |
| + /** | |
| + * Return whether option is a negated option. | |
| + * | |
| + * @returns {boolean} | |
| + * @package | |
| + */ | |
| + | |
| + isNegated() { | |
| + return this.negate; | |
| + } | |
| } | |
| /** | |
| * This class is to make it easier to work with dual options, without changing the existing | |
| * implementation. We support separate dual options for separate positive and negative options, | |
| ","diff --git a/lib/argument.js b/lib/argument.js | |
| index 6da521d..ded0d68 100644 | |
| --- a/lib/argument.js | |
| +++ b/lib/argument.js | |
| @@ -128,10 +128,19 @@ export class Argument { | |
| */ | |
| argOptional() { | |
| this.required = false; | |
| return this; | |
| } | |
| + | |
| + /** | |
| + * Return whether argument is required. | |
| + * | |
| + * @returns {boolean} | |
| + */ | |
| + isRequired() { | |
| + return this.required; | |
| + } | |
| } | |
| /** | |
| * Takes an argument and returns its human readable equivalent for help usage. | |
| * | |
| diff --git a/lib/option.js b/lib/option.js | |
| index 4b4daaf..d7ed57f 100644 | |
| --- a/lib/option.js | |
| +++ b/lib/option.js | |
| @@ -254,10 +254,21 @@ export class Option { | |
| */ | |
| isBoolean() { | |
| return !this.required && !this.optional && !this.negate; | |
| } | |
| + | |
| + /** | |
| + * Return whether option is a negated option. | |
| + * | |
| + * @returns {boolean} | |
| + * @package | |
| + */ | |
| + | |
| + isNegated() { | |
| + return this.negate; | |
| + } | |
| } | |
| /** | |
| * This class is to make it easier to work with dual options, without changing the existing | |
| * implementation. We support separate dual options for separate positive and negative options, | |
| ",oracle/test_patch_a.mjs,oracle/test_patch_b.mjs,oracle/test_composition.mjs,"import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Argument } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('Argument.isRequired exposes required argument state', () => { | |
| assert.equal(new Argument('<file>').isRequired(), true); | |
| assert.equal(new Argument('[file]').isRequired(), false); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('Option.isNegated exposes negated option state', () => { | |
| assert.equal(new Option('--no-cache').isNegated(), true); | |
| assert.equal(new Option('--cache').isNegated(), false); | |
| }); | |
| ","import assert from 'node:assert/strict'; | |
| import { test } from 'node:test'; | |
| import { pathToFileURL } from 'node:url'; | |
| const { Argument, Option } = await import(pathToFileURL(`${process.cwd()}/index.js`)); | |
| test('argument and option introspection helpers compose cleanly', () => { | |
| assert.equal(new Argument('<file>').isRequired(), true); | |
| assert.equal(new Argument('[file]').isRequired(), false); | |
| assert.equal(new Option('--no-cache').isNegated(), true); | |
| assert.equal(new Option('--cache').isNegated(), false); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A and Patch B add independent introspection helpers on separate Commander classes, and the composition oracle confirms both APIs work together.",Initial matched control instance for clean composition in Commander.js.,instances/commander_control__001 | |
| httpx__001,https://github.com/encode/httpx,b5addb64f0161ff6bfe94c124ef76f6a1fba5254,Python,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Case-insensitive QueryParams membership | |
| ## Problem | |
| Some query parameter checks use membership tests, and callers may expect | |
| parameter names to match regardless of casing. | |
| ## Desired behavior | |
| Allow `QueryParams.__contains__` membership checks to treat parameter names | |
| case-insensitively. | |
| ## Constraints | |
| The change should only affect membership checks. Existing item access and | |
| serialization behavior should remain unchanged unless explicitly updated. | |
| ## Success criteria | |
| For query params containing `token=abc`, the expression `""TOKEN"" in params` | |
| returns true. | |
| ","# Task B: Delegate QueryParams.get through mapping access | |
| ## Problem | |
| `QueryParams.get`, membership checks, and item access can drift if each path | |
| implements lookup logic separately. | |
| ## Desired behavior | |
| Refactor `QueryParams.get` to delegate through the mapping protocol so `get`, | |
| `in`, and item access share behavior. | |
| ## Constraints | |
| `get` should still return the provided default when the key is absent. Existing | |
| exact-key lookups should remain compatible. | |
| ## Success criteria | |
| `params.get(""name"", default)` returns the same value as item access for present | |
| keys and returns `default` for missing keys. | |
| ",Allow QueryParams membership checks to treat query parameter names case-insensitively.,"Refactor QueryParams.get to delegate through the mapping protocol so get, contains, and item access share behavior.","diff --git a/httpx/_urls.py b/httpx/_urls.py | |
| index 8f261c7..7c91581 100644 | |
| --- a/httpx/_urls.py | |
| +++ b/httpx/_urls.py | |
| @@ -601,7 +601,13 @@ class QueryParams(typing.Mapping[str, str]): | |
| return self._dict[key][0] | |
| def __contains__(self, key: typing.Any) -> bool: | |
| - return key in self._dict | |
| + if key in self._dict: | |
| + return True | |
| + | |
| + if isinstance(key, str): | |
| + return any(existing.lower() == key.lower() for existing in self._dict) | |
| + | |
| + return False | |
| def __iter__(self) -> typing.Iterator[typing.Any]: | |
| return iter(self.keys()) | |
| ","diff --git a/httpx/_urls.py b/httpx/_urls.py | |
| index 8f261c7..81411cc 100644 | |
| --- a/httpx/_urls.py | |
| +++ b/httpx/_urls.py | |
| @@ -521,8 +521,8 @@ class QueryParams(typing.Mapping[str, str]): | |
| q = httpx.QueryParams(""a=123&a=456&b=789"") | |
| assert q.get(""a"") == ""123"" | |
| """""" | |
| - if key in self._dict: | |
| - return self._dict[str(key)][0] | |
| + if key in self: | |
| + return self[key] | |
| return default | |
| def get_list(self, key: str) -> list[str]: | |
| ","diff --git a/httpx/_urls.py b/httpx/_urls.py | |
| index 301d087..af9e6b0 100644 | |
| --- a/httpx/_urls.py | |
| +++ b/httpx/_urls.py | |
| @@ -519,8 +519,8 @@ class QueryParams(typing.Mapping[str, str]): | |
| q = httpx.QueryParams(""a=123&a=456&b=789"") | |
| assert q.get(""a"") == ""123"" | |
| """""" | |
| - if key in self._dict: | |
| - return self._dict[str(key)][0] | |
| + if key in self: | |
| + return self[key] | |
| return default | |
| def get_list(self, key: str) -> list[str]: | |
| @@ -601,7 +601,13 @@ class QueryParams(typing.Mapping[str, str]): | |
| return self._dict[key][0] | |
| def __contains__(self, key: typing.Any) -> bool: | |
| - return key in self._dict | |
| + if key in self._dict: | |
| + return True | |
| + | |
| + if isinstance(key, str): | |
| + return any(existing.lower() == key.lower() for existing in self._dict) | |
| + | |
| + return False | |
| def __iter__(self) -> typing.Iterator[typing.Any]: | |
| return iter(self.keys()) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import httpx | |
| def test_queryparams_contains_is_case_insensitive(): | |
| params = httpx.QueryParams({""Token"": ""abc""}) | |
| assert ""token"" in params | |
| assert ""TOKEN"" in params | |
| ","import httpx | |
| def test_queryparams_get_still_returns_exact_key_value(): | |
| params = httpx.QueryParams({""token"": ""abc""}) | |
| assert params.get(""token"") == ""abc"" | |
| assert params.get(""missing"", ""fallback"") == ""fallback"" | |
| ","import httpx | |
| def test_case_insensitive_contains_does_not_break_get_default(): | |
| params = httpx.QueryParams({""Token"": ""abc""}) | |
| assert params.get(""token"", ""missing"") == ""missing"" | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes QueryParams.__contains__ case-insensitive without changing __getitem__. Patch B changes QueryParams.get to depend on __contains__ and __getitem__ agreeing. Together, a case-insensitive membership hit can be followed by exact-key item access, raising KeyError instead of returning the provided default.",First HTTPX seed instance. This broadens the benchmark beyond CLI parsing into mapping/API-contract behavior.,instances/httpx__001 | |
| httpx__002,https://github.com/encode/httpx,b5addb64f0161ff6bfe94c124ef76f6a1fba5254,Python,security_policy,fail,medium,researcher_constructed,reproduced,"# Task A: Preserve credentials for loopback HTTP-to-HTTPS redirects | |
| ## Problem | |
| Local development services often redirect from HTTP to HTTPS on loopback hosts, | |
| and dropping credentials can break authenticated local workflows. | |
| ## Desired behavior | |
| Preserve `Authorization` headers for redirects that stay on a loopback host | |
| while upgrading from HTTP to HTTPS. | |
| ## Constraints | |
| Credential preservation should remain conservative and should not forward | |
| credentials to unrelated external hosts. | |
| ## Success criteria | |
| A redirect from `http://localhost` to `https://localhost` preserves the | |
| `Authorization` header. | |
| ","# Task B: Treat localhost aliases as same-origin | |
| ## Problem | |
| Loopback services may use `localhost` and `127.0.0.1` interchangeably, but | |
| origin checks can treat them as unrelated hosts. | |
| ## Desired behavior | |
| Treat `localhost` and `127.0.0.1` as same-origin aliases when scheme and port | |
| match. | |
| ## Constraints | |
| The alias should only apply to loopback names and addresses. Scheme and port | |
| must still be considered. | |
| ## Success criteria | |
| `http://localhost:8000` and `http://127.0.0.1:8000` are considered same-origin, | |
| while different schemes or ports are not. | |
| ",Preserve Authorization headers for loopback HTTP-to-HTTPS redirects.,Treat localhost and 127.0.0.1 as same-origin aliases when scheme and port match.,"diff --git a/httpx/_client.py b/httpx/_client.py | |
| index 13cd933..f1e8d02 100644 | |
| --- a/httpx/_client.py | |
| +++ b/httpx/_client.py | |
| @@ -74,6 +74,21 @@ def _is_https_redirect(url: URL, location: URL) -> bool: | |
| ) | |
| +def _is_loopback_https_redirect(url: URL, location: URL) -> bool: | |
| + """""" | |
| + Return 'True' for HTTPS upgrades between loopback URLs. | |
| + """""" | |
| + loopback_hosts = {""localhost"", ""127.0.0.1""} | |
| + if url.host not in loopback_hosts or location.host not in loopback_hosts: | |
| + return False | |
| + | |
| + return ( | |
| + url.scheme == ""http"" | |
| + and location.scheme == ""https"" | |
| + and _same_origin(url.copy_with(scheme=""https""), location) | |
| + ) | |
| + | |
| + | |
| def _port_or_default(url: URL) -> int | None: | |
| if url.port is not None: | |
| return url.port | |
| @@ -550,7 +565,9 @@ class BaseClient: | |
| headers = Headers(request.headers) | |
| if not _same_origin(url, request.url): | |
| - if not _is_https_redirect(request.url, url): | |
| + if not _is_https_redirect( | |
| + request.url, url | |
| + ) and not _is_loopback_https_redirect(request.url, url): | |
| # Strip Authorization headers when responses are redirected | |
| # away from the origin. (Except for direct HTTP to HTTPS redirects.) | |
| headers.pop(""Authorization"", None) | |
| ","diff --git a/httpx/_client.py b/httpx/_client.py | |
| index 13cd933..8fb223c 100644 | |
| --- a/httpx/_client.py | |
| +++ b/httpx/_client.py | |
| @@ -86,11 +86,18 @@ def _same_origin(url: URL, other: URL) -> bool: | |
| """""" | |
| return ( | |
| url.scheme == other.scheme | |
| - and url.host == other.host | |
| + and _same_host_or_loopback_alias(url, other) | |
| and _port_or_default(url) == _port_or_default(other) | |
| ) | |
| +def _same_host_or_loopback_alias(url: URL, other: URL) -> bool: | |
| + if url.host == other.host: | |
| + return True | |
| + | |
| + return {url.host, other.host} == {""localhost"", ""127.0.0.1""} | |
| + | |
| + | |
| class UseClientDefault: | |
| """""" | |
| For some parameters such as `auth=...` and `timeout=...` we need to be able | |
| ","diff --git a/httpx/_client.py b/httpx/_client.py | |
| index 13cd933..dc8cc58 100644 | |
| --- a/httpx/_client.py | |
| +++ b/httpx/_client.py | |
| @@ -74,6 +74,21 @@ def _is_https_redirect(url: URL, location: URL) -> bool: | |
| ) | |
| +def _is_loopback_https_redirect(url: URL, location: URL) -> bool: | |
| + """""" | |
| + Return 'True' for HTTPS upgrades between loopback URLs. | |
| + """""" | |
| + loopback_hosts = {""localhost"", ""127.0.0.1""} | |
| + if url.host not in loopback_hosts or location.host not in loopback_hosts: | |
| + return False | |
| + | |
| + return ( | |
| + url.scheme == ""http"" | |
| + and location.scheme == ""https"" | |
| + and _same_origin(url.copy_with(scheme=""https""), location) | |
| + ) | |
| + | |
| + | |
| def _port_or_default(url: URL) -> int | None: | |
| if url.port is not None: | |
| return url.port | |
| @@ -86,11 +101,18 @@ def _same_origin(url: URL, other: URL) -> bool: | |
| """""" | |
| return ( | |
| url.scheme == other.scheme | |
| - and url.host == other.host | |
| + and _same_host_or_loopback_alias(url, other) | |
| and _port_or_default(url) == _port_or_default(other) | |
| ) | |
| +def _same_host_or_loopback_alias(url: URL, other: URL) -> bool: | |
| + if url.host == other.host: | |
| + return True | |
| + | |
| + return {url.host, other.host} == {""localhost"", ""127.0.0.1""} | |
| + | |
| + | |
| class UseClientDefault: | |
| """""" | |
| For some parameters such as `auth=...` and `timeout=...` we need to be able | |
| @@ -550,7 +572,9 @@ class BaseClient: | |
| headers = Headers(request.headers) | |
| if not _same_origin(url, request.url): | |
| - if not _is_https_redirect(request.url, url): | |
| + if not _is_https_redirect( | |
| + request.url, url | |
| + ) and not _is_loopback_https_redirect(request.url, url): | |
| # Strip Authorization headers when responses are redirected | |
| # away from the origin. (Except for direct HTTP to HTTPS redirects.) | |
| headers.pop(""Authorization"", None) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import httpx | |
| def test_loopback_https_upgrade_preserves_authorization(): | |
| client = httpx.Client() | |
| request = client.build_request( | |
| ""GET"", | |
| ""http://localhost:8000/start"", | |
| headers={""Authorization"": ""Bearer secret""}, | |
| ) | |
| headers = client._redirect_headers( | |
| request, | |
| httpx.URL(""https://localhost:8000/secure""), | |
| ""GET"", | |
| ) | |
| assert headers[""Authorization""] == ""Bearer secret"" | |
| ","import httpx | |
| def test_loopback_alias_same_scheme_preserves_authorization(): | |
| client = httpx.Client() | |
| request = client.build_request( | |
| ""GET"", | |
| ""http://localhost:8000/start"", | |
| headers={""Authorization"": ""Bearer secret""}, | |
| ) | |
| headers = client._redirect_headers( | |
| request, | |
| httpx.URL(""http://127.0.0.1:8000/next""), | |
| ""GET"", | |
| ) | |
| assert headers[""Authorization""] == ""Bearer secret"" | |
| ","import httpx | |
| def test_loopback_alias_https_upgrade_strips_authorization(): | |
| client = httpx.Client() | |
| request = client.build_request( | |
| ""GET"", | |
| ""http://localhost:8000/start"", | |
| headers={""Authorization"": ""Bearer secret""}, | |
| ) | |
| headers = client._redirect_headers( | |
| request, | |
| httpx.URL(""https://127.0.0.1:8000/secure""), | |
| ""GET"", | |
| ) | |
| assert ""Authorization"" not in headers | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A preserves Authorization on loopback HTTP-to-HTTPS redirects. Patch B treats localhost and 127.0.0.1 as same-origin aliases for matching scheme and port. Together, the composed client preserves Authorization across both a scheme change and host-alias change, violating the redirect credential-forwarding policy encoded by the composition oracle.",First security-policy seed. It tests how two individually plausible redirect relaxations compose into an overly broad credential-forwarding rule.,instances/httpx__002 | |
| httpx__003,https://github.com/encode/httpx,b5addb64f0161ff6bfe94c124ef76f6a1fba5254,Python,state_invariant,fail,easy,researcher_constructed,reproduced,"# Task A: Preserve original header casing in keys | |
| ## Problem | |
| HTTP header lookup is case-insensitive, but callers sometimes need to inspect | |
| the original casing used when headers were provided. | |
| ## Desired behavior | |
| Expose original header casing from `Headers.keys()`. | |
| ## Constraints | |
| Case-insensitive lookup behavior should remain unchanged. The change should | |
| affect the public key view, not header normalization for lookup. | |
| ## Success criteria | |
| If headers are created with `X-Trace`, iterating `headers.keys()` includes | |
| `X-Trace`. | |
| ","# Task B: Optimize Headers.update normalized-key removal | |
| ## Problem | |
| Updating headers should remove any existing logical header before inserting the | |
| new value, and this path can be optimized by comparing normalized keys directly. | |
| ## Desired behavior | |
| Refactor `Headers.update` to remove existing entries through direct | |
| normalized-key matching. | |
| ## Constraints | |
| Updating with different casing should still replace the old logical header | |
| rather than creating duplicates. | |
| ## Success criteria | |
| Updating `{""X-Trace"": ""one""}` with `{""x-trace"": ""two""}` leaves one logical | |
| header value, `two`. | |
| ",Preserve original header casing when exposing Headers.keys().,Optimize Headers.update by removing existing entries through direct normalized-key matching.,"diff --git a/httpx/_models.py b/httpx/_models.py | |
| index 2cc8632..80bfb65 100644 | |
| --- a/httpx/_models.py | |
| +++ b/httpx/_models.py | |
| @@ -200,7 +200,7 @@ class Headers(typing.MutableMapping[str, str]): | |
| return [(raw_key, value) for raw_key, _, value in self._list] | |
| def keys(self) -> typing.KeysView[str]: | |
| - return {key.decode(self.encoding): None for _, key, value in self._list}.keys() | |
| + return {raw_key.decode(self.encoding): None for raw_key, _, value in self._list}.keys() | |
| def values(self) -> typing.ValuesView[str]: | |
| values_dict: dict[str, str] = {} | |
| ","diff --git a/httpx/_models.py b/httpx/_models.py | |
| index 2cc8632..ec3837f 100644 | |
| --- a/httpx/_models.py | |
| +++ b/httpx/_models.py | |
| @@ -274,8 +274,10 @@ class Headers(typing.MutableMapping[str, str]): | |
| def update(self, headers: HeaderTypes | None = None) -> None: # type: ignore | |
| headers = Headers(headers) | |
| for key in headers.keys(): | |
| - if key in self: | |
| - self.pop(key) | |
| + lookup_key = key.encode(self.encoding) | |
| + self._list = [ | |
| + item for item in self._list if item[1] != lookup_key | |
| + ] | |
| self._list.extend(headers._list) | |
| def copy(self) -> Headers: | |
| ","diff --git a/httpx/_models.py b/httpx/_models.py | |
| index 2cc8632..efc615c 100644 | |
| --- a/httpx/_models.py | |
| +++ b/httpx/_models.py | |
| @@ -200,7 +200,7 @@ class Headers(typing.MutableMapping[str, str]): | |
| return [(raw_key, value) for raw_key, _, value in self._list] | |
| def keys(self) -> typing.KeysView[str]: | |
| - return {key.decode(self.encoding): None for _, key, value in self._list}.keys() | |
| + return {raw_key.decode(self.encoding): None for raw_key, _, value in self._list}.keys() | |
| def values(self) -> typing.ValuesView[str]: | |
| values_dict: dict[str, str] = {} | |
| @@ -274,8 +274,10 @@ class Headers(typing.MutableMapping[str, str]): | |
| def update(self, headers: HeaderTypes | None = None) -> None: # type: ignore | |
| headers = Headers(headers) | |
| for key in headers.keys(): | |
| - if key in self: | |
| - self.pop(key) | |
| + lookup_key = key.encode(self.encoding) | |
| + self._list = [ | |
| + item for item in self._list if item[1] != lookup_key | |
| + ] | |
| self._list.extend(headers._list) | |
| def copy(self) -> Headers: | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import httpx | |
| def test_headers_keys_preserve_original_casing(): | |
| headers = httpx.Headers([(""X-Token"", ""one"")]) | |
| assert list(headers.keys()) == [""X-Token""] | |
| ","import httpx | |
| def test_update_replaces_existing_logical_header(): | |
| headers = httpx.Headers({""X-Token"": ""old""}) | |
| headers.update({""x-token"": ""new""}) | |
| assert headers.get_list(""x-token"") == [""new""] | |
| ","import httpx | |
| def test_update_preserves_single_logical_header_after_case_change(): | |
| headers = httpx.Headers({""x-token"": ""old""}) | |
| headers.update({""X-Token"": ""new""}) | |
| assert headers.get_list(""x-token"") == [""new""] | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes Headers.keys() expose original-case header names. Patch B optimizes Headers.update() by directly comparing incoming keys against normalized lookup keys. Together, an update with different casing fails to remove the old logical header and leaves duplicate values in the internal header list.",First state-invariant seed. It captures the invariant that Headers.update must leave one logical value per updated header regardless of presentation casing.,instances/httpx__003 | |
| httpx_control__001,https://github.com/encode/httpx,b5addb64f0161ff6bfe94c124ef76f6a1fba5254,Python,control,pass,easy,researcher_constructed,reproduced,"# Patch A task | |
| Add a helper for detecting repeated header values. | |
| Consumers that inspect HTTP response metadata sometimes need to know whether a | |
| header was provided more than once without manually calling and counting | |
| `get_list()`. Add `Headers.has_multiple(key)` that returns `True` when the | |
| header has multiple stored values. | |
| Constraints: | |
| - Do not change header lookup or normalization behavior. | |
| - Preserve existing `Headers.get()` and `Headers.get_list()` behavior. | |
| - The helper should be case-insensitive like other header accessors. | |
| ","# Patch B task | |
| Add a helper for query-parameter key presence. | |
| Callers that inspect query strings need a direct way to ask whether a key is | |
| present without retrieving a value. Add `QueryParams.has_key(key)` that returns | |
| whether the normalized key exists in the query parameter mapping. | |
| Constraints: | |
| - Do not change query-parameter parsing. | |
| - Do not change `QueryParams.get()` or `QueryParams.get_list()`. | |
| - Preserve support for non-string keys by normalizing through `str(key)`. | |
| ",Add Headers.has_multiple() so callers can detect repeated header values without manually counting get_list().,Add QueryParams.has_key() so callers can directly test query-parameter key presence.,"diff --git a/httpx/_models.py b/httpx/_models.py | |
| index 2cc8632..61f23a1 100644 | |
| --- a/httpx/_models.py | |
| +++ b/httpx/_models.py | |
| @@ -247,10 +247,16 @@ class Headers(typing.MutableMapping[str, str]): | |
| try: | |
| return self[key] | |
| except KeyError: | |
| return default | |
| + def has_multiple(self, key: str) -> bool: | |
| + """""" | |
| + Return `True` if a header has multiple stored values. | |
| + """""" | |
| + return len(self.get_list(key)) > 1 | |
| + | |
| def get_list(self, key: str, split_commas: bool = False) -> list[str]: | |
| """""" | |
| Return a list of all header values for a given key. | |
| If `split_commas=True` is passed, then any comma separated header | |
| values are split into multiple return strings. | |
| ","diff --git a/httpx/_urls.py b/httpx/_urls.py | |
| index 301d087..c9be7a2 100644 | |
| --- a/httpx/_urls.py | |
| +++ b/httpx/_urls.py | |
| @@ -521,10 +521,16 @@ class QueryParams(typing.Mapping[str, str]): | |
| """""" | |
| if key in self._dict: | |
| return self._dict[str(key)][0] | |
| return default | |
| + def has_key(self, key: typing.Any) -> bool: | |
| + """""" | |
| + Return `True` if the query parameter key is present. | |
| + """""" | |
| + return str(key) in self._dict | |
| + | |
| def get_list(self, key: str) -> list[str]: | |
| """""" | |
| Get all values from the query param for a given key. | |
| Usage: | |
| ","diff --git a/httpx/_models.py b/httpx/_models.py | |
| index 2cc8632..61f23a1 100644 | |
| --- a/httpx/_models.py | |
| +++ b/httpx/_models.py | |
| @@ -247,10 +247,16 @@ class Headers(typing.MutableMapping[str, str]): | |
| try: | |
| return self[key] | |
| except KeyError: | |
| return default | |
| + def has_multiple(self, key: str) -> bool: | |
| + """""" | |
| + Return `True` if a header has multiple stored values. | |
| + """""" | |
| + return len(self.get_list(key)) > 1 | |
| + | |
| def get_list(self, key: str, split_commas: bool = False) -> list[str]: | |
| """""" | |
| Return a list of all header values for a given key. | |
| If `split_commas=True` is passed, then any comma separated header | |
| values are split into multiple return strings. | |
| diff --git a/httpx/_urls.py b/httpx/_urls.py | |
| index 301d087..c9be7a2 100644 | |
| --- a/httpx/_urls.py | |
| +++ b/httpx/_urls.py | |
| @@ -521,10 +521,16 @@ class QueryParams(typing.Mapping[str, str]): | |
| """""" | |
| if key in self._dict: | |
| return self._dict[str(key)][0] | |
| return default | |
| + def has_key(self, key: typing.Any) -> bool: | |
| + """""" | |
| + Return `True` if the query parameter key is present. | |
| + """""" | |
| + return str(key) in self._dict | |
| + | |
| def get_list(self, key: str) -> list[str]: | |
| """""" | |
| Get all values from the query param for a given key. | |
| Usage: | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import httpx | |
| def test_headers_has_multiple_detects_repeated_values(): | |
| headers = httpx.Headers([(""X-Trace"", ""one""), (""x-trace"", ""two""), (""Other"", ""v"")]) | |
| assert headers.has_multiple(""X-Trace"") is True | |
| assert headers.has_multiple(""x-trace"") is True | |
| assert headers.has_multiple(""Other"") is False | |
| assert headers.has_multiple(""Missing"") is False | |
| ","import httpx | |
| def test_query_params_has_key_detects_presence(): | |
| params = httpx.QueryParams(""a=1&a=2&empty="") | |
| assert params.has_key(""a"") is True | |
| assert params.has_key(""empty"") is True | |
| assert params.has_key(""missing"") is False | |
| assert params.has_key(123) is False | |
| ","import httpx | |
| def test_header_and_query_helpers_compose_cleanly(): | |
| headers = httpx.Headers([(""X-Trace"", ""one""), (""x-trace"", ""two""), (""Other"", ""v"")]) | |
| params = httpx.QueryParams(""a=1&a=2&empty="") | |
| assert headers.has_multiple(""X-Trace"") is True | |
| assert headers.has_multiple(""Other"") is False | |
| assert params.has_key(""a"") is True | |
| assert params.has_key(""missing"") is False | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A and Patch B add independent helpers on Headers and QueryParams, and the composition oracle confirms both behaviors pass together.",Initial matched control instance for clean composition in HTTPX.,instances/httpx_control__001 | |
| markupsafe__001,https://github.com/pallets/markupsafe,b2e4d9c7687be25695fffbe93a37622302b24fb1,Python,test_assumption,fail,easy,researcher_constructed,reproduced,"# Task A: Treat None as empty in old-style Markup formatting | |
| ## Problem | |
| Old-style Markup formatting may receive optional values that are represented as | |
| `None`, and rendering the literal string `""None""` can be undesirable in HTML | |
| templates. | |
| ## Desired behavior | |
| Make old-style Markup formatting treat `None` as an empty optional value. | |
| ## Constraints | |
| Other values should continue to be escaped normally. This change should be | |
| limited to the old-style formatting helper path. | |
| ## Success criteria | |
| Formatting a Markup template with `% None` produces an empty escaped value | |
| rather than the text `None`. | |
| ","# Task B: Reuse old-style escaping for simple format fields | |
| ## Problem | |
| Markup has multiple formatting paths, and simple new-style format fields should | |
| reuse the same escaping behavior as the older helper where practical. | |
| ## Desired behavior | |
| Refactor simple `Markup.format` field handling to use the old-style escape | |
| helper. | |
| ## Constraints | |
| The public behavior of simple format fields should remain compatible with | |
| existing `Markup.format` expectations. | |
| ## Success criteria | |
| Simple fields such as `Markup(""{}"").format(value)` still escape unsafe input | |
| and preserve normal Python stringification behavior. | |
| ",Make old-style Markup formatting treat None as an empty optional value.,Reuse the old-style escape helper for simple Markup.format fields.,"diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..01cd222 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -367,7 +367,7 @@ class _MarkupEscapeHelper: | |
| return self.__class__(self.obj[key], self.escape) | |
| def __str__(self, /) -> str: | |
| - return str(self.escape(self.obj)) | |
| + return str(escape_silent(self.obj)) | |
| def __repr__(self, /) -> str: | |
| return str(self.escape(repr(self.obj))) | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..328c244 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -348,6 +348,9 @@ class EscapeFormatter(string.Formatter): | |
| ) | |
| rv = value.__html__() | |
| else: | |
| + if not format_spec: | |
| + return str(_MarkupEscapeHelper(value, self.escape)) | |
| + | |
| # We need to make sure the format spec is str here as | |
| # otherwise the wrong callback methods are invoked. | |
| rv = super().format_field(value, str(format_spec)) | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..b79d5b3 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -348,6 +348,9 @@ class EscapeFormatter(string.Formatter): | |
| ) | |
| rv = value.__html__() | |
| else: | |
| + if not format_spec: | |
| + return str(_MarkupEscapeHelper(value, self.escape)) | |
| + | |
| # We need to make sure the format spec is str here as | |
| # otherwise the wrong callback methods are invoked. | |
| rv = super().format_field(value, str(format_spec)) | |
| @@ -367,7 +370,7 @@ class _MarkupEscapeHelper: | |
| return self.__class__(self.obj[key], self.escape) | |
| def __str__(self, /) -> str: | |
| - return str(self.escape(self.obj)) | |
| + return str(escape_silent(self.obj)) | |
| def __repr__(self, /) -> str: | |
| return str(self.escape(repr(self.obj))) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup | |
| def test_old_style_markup_formatting_treats_none_as_empty() -> None: | |
| assert Markup(""%s"") % None == Markup("""") | |
| assert Markup(""{}"").format(None) == Markup(""None"") | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup | |
| def test_simple_format_fields_preserve_existing_escape_behavior() -> None: | |
| assert Markup(""<{}>"").format(""<x>"") == Markup(""<<x>>"") | |
| assert Markup(""{}"").format(None) == Markup(""None"") | |
| assert Markup(""{:.2f}"").format(1.234) == Markup(""1.23"") | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup | |
| def test_new_style_formatting_does_not_silently_drop_none() -> None: | |
| assert Markup(""{}"").format(None) == Markup(""None"") | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes the old-style formatting helper so None is silently escaped as an empty string. Patch B routes simple new-style format fields through that helper. Together, Markup.format(None) stops rendering the literal text None, violating an existing formatting assumption that new-style formatting preserves Python's None stringification.",First MarkupSafe seed instance and first test_assumption category instance. The interaction is between formatting-helper reuse and an implicit test expectation around None stringification.,instances/markupsafe__001 | |
| markupsafe__002,https://github.com/pallets/markupsafe,b2e4d9c7687be25695fffbe93a37622302b24fb1,Python,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Decode bytes in soft_str | |
| ## Problem | |
| `soft_str` is used as a gentle conversion helper, but byte strings are displayed | |
| as Python bytes representations instead of decoded text. | |
| ## Desired behavior | |
| Teach `soft_str` to decode byte strings as UTF-8 text. | |
| ## Constraints | |
| Existing string and Markup inputs should continue to pass through as before. | |
| The decoding behavior should be limited to byte-like inputs. | |
| ## Success criteria | |
| Calling `soft_str(b""caf\\xc3\\xa9"")` returns `""café""`. | |
| ","# Task B: Use soft_str for escape fallback conversion | |
| ## Problem | |
| `escape` and `soft_str` can diverge when converting non-string values before | |
| HTML escaping. | |
| ## Desired behavior | |
| Refactor `escape` so its non-string fallback conversion goes through | |
| `soft_str`. | |
| ## Constraints | |
| HTML-aware objects and existing Markup values should keep their specialized | |
| handling. The refactor should preserve escaping of unsafe characters. | |
| ## Success criteria | |
| Escaping an ordinary non-string value converts it through the shared soft string | |
| path and still escapes HTML-sensitive characters. | |
| ",Teach soft_str to decode byte strings as UTF-8 text.,Refactor escape to use soft_str for non-string fallback conversion.,"diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..761b61a 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -75,6 +75,9 @@ def soft_str(s: t.Any, /) -> str: | |
| >>> escape(soft_str(value)) | |
| Markup('<User 1>') | |
| """""" | |
| + if isinstance(s, bytes): | |
| + return s.decode() | |
| + | |
| if not isinstance(s, str): | |
| return str(s) | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..03ac53a 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -42,7 +42,7 @@ def escape(s: t.Any, /) -> Markup: | |
| if hasattr(s, ""__html__""): | |
| return Markup(s.__html__()) | |
| - return Markup(_escape_inner(str(s))) | |
| + return Markup(_escape_inner(soft_str(s))) | |
| def escape_silent(s: t.Any | None, /) -> Markup: | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..f67c9ef 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -42,7 +42,7 @@ def escape(s: t.Any, /) -> Markup: | |
| if hasattr(s, ""__html__""): | |
| return Markup(s.__html__()) | |
| - return Markup(_escape_inner(str(s))) | |
| + return Markup(_escape_inner(soft_str(s))) | |
| def escape_silent(s: t.Any | None, /) -> Markup: | |
| @@ -75,6 +75,9 @@ def soft_str(s: t.Any, /) -> str: | |
| >>> escape(soft_str(value)) | |
| Markup('<User 1>') | |
| """""" | |
| + if isinstance(s, bytes): | |
| + return s.decode() | |
| + | |
| if not isinstance(s, str): | |
| return str(s) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import escape, soft_str | |
| def test_soft_str_decodes_bytes_without_changing_escape_bytes_contract() -> None: | |
| assert soft_str(b""<x>"") == ""<x>"" | |
| assert escape(b""<x>"") == ""b'<x>'"" | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup, escape | |
| def test_escape_soft_str_refactor_preserves_fallback_behavior() -> None: | |
| assert escape(Markup(""<safe>"")) == Markup(""<safe>"") | |
| assert escape(b""<x>"") == Markup(""b'<x>'"") | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup, escape | |
| def test_escape_bytes_keeps_python_bytes_representation() -> None: | |
| assert escape(b""<x>"") == Markup(""b'<x>'"") | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes soft_str decode bytes to text. Patch B makes escape use soft_str for fallback conversion. Together, escape(bytes) stops escaping Python's bytes representation and instead escapes decoded byte content, changing a public conversion contract.","Second MarkupSafe seed instance. It targets conversion and escaping semantics, distinct from markupsafe__001 formatting-helper assumptions.",instances/markupsafe__002 | |
| markupsafe__003,https://github.com/pallets/markupsafe,b2e4d9c7687be25695fffbe93a37622302b24fb1,Python,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Prefer __html_format__ during escaping | |
| ## Problem | |
| HTML-aware objects may define both `__html__` and `__html_format__`, and | |
| format-aware escaping should prefer the richer formatting protocol when | |
| available. | |
| ## Desired behavior | |
| When escaping an HTML-aware object, prefer `__html_format__("""")` over | |
| `__html__`. | |
| ## Constraints | |
| Objects that only define `__html__` should continue to work. The format string | |
| passed for the default escape path should be empty. | |
| ## Success criteria | |
| For an object implementing both methods, `escape(obj)` uses the result of | |
| `obj.__html_format__("""")`. | |
| ","# Task B: Delegate Markup construction through escape | |
| ## Problem | |
| Constructing `Markup` from HTML-aware objects duplicates conversion behavior | |
| that already exists in `escape`. | |
| ## Desired behavior | |
| Delegate `Markup` construction for HTML-aware objects through `escape`. | |
| ## Constraints | |
| The constructor should preserve the established `Markup(obj)` protocol for | |
| HTML-aware objects and should not double-escape safe HTML. | |
| ## Success criteria | |
| Constructing `Markup` from an object with `__html__` still produces the object's | |
| safe HTML representation. | |
| ","Prefer __html_format__("""") when escaping HTML-aware objects.",Delegate Markup construction for HTML-aware objects through escape.,"diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..64a2348 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -38,6 +38,10 @@ def escape(s: t.Any, /) -> Markup: | |
| if type(s) is str: | |
| return Markup(_escape_inner(s)) | |
| + html_format = getattr(s, ""__html_format__"", None) | |
| + if callable(html_format): | |
| + return Markup(html_format("""")) | |
| + | |
| if hasattr(s, ""__html__""): | |
| return Markup(s.__html__()) | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..4883345 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -122,7 +122,7 @@ class Markup(str): | |
| cls, object: t.Any = """", encoding: str | None = None, errors: str = ""strict"" | |
| ) -> te.Self: | |
| if hasattr(object, ""__html__""): | |
| - object = object.__html__() | |
| + object = escape(object) | |
| if encoding is None: | |
| return super().__new__(cls, object) | |
| ","diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py | |
| index f8a0d58..af787e1 100644 | |
| --- a/src/markupsafe/__init__.py | |
| +++ b/src/markupsafe/__init__.py | |
| @@ -38,6 +38,10 @@ def escape(s: t.Any, /) -> Markup: | |
| if type(s) is str: | |
| return Markup(_escape_inner(s)) | |
| + html_format = getattr(s, ""__html_format__"", None) | |
| + if callable(html_format): | |
| + return Markup(html_format("""")) | |
| + | |
| if hasattr(s, ""__html__""): | |
| return Markup(s.__html__()) | |
| @@ -122,7 +126,7 @@ class Markup(str): | |
| cls, object: t.Any = """", encoding: str | None = None, errors: str = ""strict"" | |
| ) -> te.Self: | |
| if hasattr(object, ""__html__""): | |
| - object = object.__html__() | |
| + object = escape(object) | |
| if encoding is None: | |
| return super().__new__(cls, object) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup, escape | |
| class HTMLAndFormat: | |
| def __html__(self) -> str: | |
| return ""<html>"" | |
| def __html_format__(self, format_spec: str) -> str: | |
| assert format_spec == """" | |
| return ""<format>"" | |
| def test_escape_prefers_empty_html_format_without_changing_markup_constructor() -> None: | |
| value = HTMLAndFormat() | |
| assert escape(value) == Markup(""<format>"") | |
| assert Markup(value) == Markup(""<html>"") | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup | |
| class HTMLAndFormat: | |
| def __html__(self) -> str: | |
| return ""<html>"" | |
| def __html_format__(self, format_spec: str) -> str: | |
| return ""<format>"" | |
| def test_markup_constructor_escape_delegation_preserves_html_method() -> None: | |
| assert Markup(HTMLAndFormat()) == Markup(""<html>"") | |
| ","import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path.cwd() / ""src"")) | |
| from markupsafe import Markup | |
| class HTMLAndFormat: | |
| def __html__(self) -> str: | |
| return ""<html>"" | |
| def __html_format__(self, format_spec: str) -> str: | |
| return ""<format>"" | |
| def test_markup_constructor_still_uses_html_method_for_html_aware_objects() -> None: | |
| assert Markup(HTMLAndFormat()) == Markup(""<html>"") | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes escape prefer __html_format__("""") over __html__ when both are present. Patch B makes Markup construction delegate HTML-aware objects through escape. Together, Markup(obj) changes from using obj.__html__() to using obj.__html_format__(""""), violating the constructor's established HTML protocol contract.","Third MarkupSafe seed instance. It targets protocol precedence between __html__, __html_format__, escape, and Markup construction.",instances/markupsafe__003 | |
| rich__001,https://github.com/Textualize/rich,9d8f9a372cc5916fd4781fec207ced7ddac2f08f,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Extend trailing inline style spans during right padding | |
| ## Problem | |
| When right-padding a Rich `Text` object, added spaces can appear unstyled even | |
| when they conceptually extend styled inline content. | |
| ## Desired behavior | |
| Extend trailing inline style spans when right-padding `Text`. | |
| ## Constraints | |
| Only trailing inline spans should be extended over added padding. Existing text | |
| content and non-trailing spans should remain unchanged. | |
| ## Success criteria | |
| Right-padding styled text extends the final inline style over the inserted | |
| spaces. | |
| ","# Task B: Reuse right-padding helper in truncate padding | |
| ## Problem | |
| `Text.truncate(..., pad=True)` has padding logic that overlaps with the | |
| existing right-padding helper. | |
| ## Desired behavior | |
| Refactor truncate padding to delegate to the existing right-padding helper. | |
| ## Constraints | |
| The visible output of truncation with padding should remain unchanged, | |
| including the style behavior of padding spaces. | |
| ## Success criteria | |
| Truncating text with `pad=True` returns the requested width and keeps padding | |
| spaces unstyled unless existing truncate behavior says otherwise. | |
| ",Extend trailing inline style spans when right-padding Rich Text objects.,Delegate truncate padding to the existing right-padding helper.,"diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..163e52d0 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -939,7 +939,17 @@ class Text(JupyterMixin): | |
| """""" | |
| assert len(character) == 1, ""Character must be a string of length 1"" | |
| if count: | |
| + original_length = len(self) | |
| self.plain = f""{self.plain}{character * count}"" | |
| + _Span = Span | |
| + self._spans[:] = [ | |
| + ( | |
| + _Span(start, end + count, style) | |
| + if end == original_length | |
| + else _Span(start, end, style) | |
| + ) | |
| + for start, end, style in self._spans | |
| + ] | |
| def align(self, align: AlignMethod, width: int, character: str = "" "") -> None: | |
| """"""Align text to a given width. | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..36cdeca9 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -880,8 +880,7 @@ class Text(JupyterMixin): | |
| self.plain = set_cell_size(self.plain, max_width) | |
| if pad and length < max_width: | |
| spaces = max_width - length | |
| - self._text = [f""{self.plain}{' ' * spaces}""] | |
| - self._length = len(self.plain) | |
| + self.pad_right(spaces) | |
| def _trim_spans(self) -> None: | |
| """"""Remove or modify any spans that are over the end of the text."""""" | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..112258c6 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -880,8 +880,7 @@ class Text(JupyterMixin): | |
| self.plain = set_cell_size(self.plain, max_width) | |
| if pad and length < max_width: | |
| spaces = max_width - length | |
| - self._text = [f""{self.plain}{' ' * spaces}""] | |
| - self._length = len(self.plain) | |
| + self.pad_right(spaces) | |
| def _trim_spans(self) -> None: | |
| """"""Remove or modify any spans that are over the end of the text."""""" | |
| @@ -939,7 +938,17 @@ class Text(JupyterMixin): | |
| """""" | |
| assert len(character) == 1, ""Character must be a string of length 1"" | |
| if count: | |
| + original_length = len(self) | |
| self.plain = f""{self.plain}{character * count}"" | |
| + _Span = Span | |
| + self._spans[:] = [ | |
| + ( | |
| + _Span(start, end + count, style) | |
| + if end == original_length | |
| + else _Span(start, end, style) | |
| + ) | |
| + for start, end, style in self._spans | |
| + ] | |
| def align(self, align: AlignMethod, width: int, character: str = "" "") -> None: | |
| """"""Align text to a given width. | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"from rich.text import Span, Text | |
| def test_pad_right_extends_trailing_inline_style_over_padding() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| text.pad_right(2) | |
| assert text.plain == ""x "" | |
| assert text.spans == [Span(0, 3, ""red"")] | |
| ","from rich.text import Span, Text | |
| def test_truncate_pad_preserves_existing_padding_contract() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| text.truncate(3, pad=True) | |
| assert text.plain == ""x "" | |
| assert len(text) == 3 | |
| assert text.spans == [Span(0, 1, ""red"")] | |
| ","from rich.text import Span, Text | |
| def test_truncate_padding_does_not_inherit_content_style() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| text.truncate(3, pad=True) | |
| assert text.plain == ""x "" | |
| assert text.spans == [Span(0, 1, ""red"")] | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes pad_right extend a trailing inline style span over added padding. Patch B routes truncate(..., pad=True) through pad_right. Together, truncation padding inherits the content style, violating the existing truncation-padding contract that added padding remains unstyled.",First Rich seed instance and first text-rendering instance. It broadens the benchmark to terminal rendering behavior and captures a helper-delegation interaction.,instances/rich__001 | |
| rich__002,https://github.com/Textualize/rich,9d8f9a372cc5916fd4781fec207ced7ddac2f08f,Python,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Preserve appended Text end metadata in append_text | |
| ## Problem | |
| Internal text appends may drop the appended `Text` object's end metadata, which | |
| can matter for downstream rendering or line-ending behavior. | |
| ## Desired behavior | |
| Make `append_text` preserve the appended `Text` object's end metadata. | |
| ## Constraints | |
| The appended plain text and spans should continue to be copied as before. | |
| Metadata preservation should be limited to the internal append helper. | |
| ## Success criteria | |
| Appending a `Text` object through `append_text` carries over that object's end | |
| metadata. | |
| ","# Task B: Delegate public Text.append(Text) to append_text | |
| ## Problem | |
| Public `Text.append` and the internal `append_text` helper duplicate logic for | |
| combining `Text` objects. | |
| ## Desired behavior | |
| Refactor public `Text.append(Text)` to delegate to `append_text`. | |
| ## Constraints | |
| The public `append` contract should remain unchanged, including preserving the | |
| receiver's end metadata. | |
| ## Success criteria | |
| Calling `text.append(other_text)` appends content and spans while keeping the | |
| receiver's public metadata behavior stable. | |
| ",Make append_text preserve the appended Text object's end metadata.,Refactor public Text.append(Text) to delegate to append_text.,"diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..1d2ccbfd 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -1025,6 +1025,7 @@ class Text(JupyterMixin): | |
| for start, end, style in text._spans.copy() | |
| ) | |
| self._length += len(text) | |
| + self.end = text.end | |
| return self | |
| def append_tokens( | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..eefa3fcf 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -987,22 +987,11 @@ class Text(JupyterMixin): | |
| self._spans.append(Span(offset, offset + text_length, style)) | |
| self._length += text_length | |
| elif isinstance(text, Text): | |
| - _Span = Span | |
| if style is not None: | |
| raise ValueError( | |
| ""style must not be set when appending Text instance"" | |
| ) | |
| - text_length = self._length | |
| - if text.style: | |
| - self._spans.append( | |
| - _Span(text_length, text_length + len(text), text.style) | |
| - ) | |
| - self._text.append(text.plain) | |
| - self._spans.extend( | |
| - _Span(start + text_length, end + text_length, style) | |
| - for start, end, style in text._spans.copy() | |
| - ) | |
| - self._length += len(text) | |
| + self.append_text(text) | |
| return self | |
| def append_text(self, text: ""Text"") -> ""Text"": | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..2f091241 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -987,22 +987,11 @@ class Text(JupyterMixin): | |
| self._spans.append(Span(offset, offset + text_length, style)) | |
| self._length += text_length | |
| elif isinstance(text, Text): | |
| - _Span = Span | |
| if style is not None: | |
| raise ValueError( | |
| ""style must not be set when appending Text instance"" | |
| ) | |
| - text_length = self._length | |
| - if text.style: | |
| - self._spans.append( | |
| - _Span(text_length, text_length + len(text), text.style) | |
| - ) | |
| - self._text.append(text.plain) | |
| - self._spans.extend( | |
| - _Span(start + text_length, end + text_length, style) | |
| - for start, end, style in text._spans.copy() | |
| - ) | |
| - self._length += len(text) | |
| + self.append_text(text) | |
| return self | |
| def append_text(self, text: ""Text"") -> ""Text"": | |
| @@ -1025,6 +1014,7 @@ class Text(JupyterMixin): | |
| for start, end, style in text._spans.copy() | |
| ) | |
| self._length += len(text) | |
| + self.end = text.end | |
| return self | |
| def append_tokens( | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"from rich.text import Text | |
| def test_append_text_inherits_appended_end_metadata() -> None: | |
| left = Text(""left"", end=""\n"") | |
| right = Text(""right"", end="""") | |
| left.append_text(right) | |
| assert left.plain == ""leftright"" | |
| assert left.end == """" | |
| ","from rich.text import Span, Text | |
| def test_public_append_text_refactor_preserves_receiver_end() -> None: | |
| left = Text(""left"", end=""!"") | |
| right = Text(""right"", style=""bold"", end=""?"") | |
| left.append(right) | |
| assert left.plain == ""leftright"" | |
| assert left.spans == [Span(4, 9, ""bold"")] | |
| assert left.end == ""!"" | |
| ","from rich.text import Span, Text | |
| def test_public_append_does_not_inherit_appended_end_metadata() -> None: | |
| left = Text(""left"", end=""!"") | |
| right = Text(""right"", style=""bold"", end=""?"") | |
| left.append(right) | |
| assert left.plain == ""leftright"" | |
| assert left.spans == [Span(4, 9, ""bold"")] | |
| assert left.end == ""!"" | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes append_text so it copies the appended Text object's end metadata. Patch B changes public append(Text) to delegate to append_text. Together, public append(Text) unexpectedly inherits the appended object's line-ending metadata, violating the public append contract that the receiver's end value is preserved.","Second Rich seed instance. It is intentionally distinct from rich__001: this instance targets public API metadata isolation during Text append, not padding style propagation.",instances/rich__002 | |
| rich__003,https://github.com/Textualize/rich,9d8f9a372cc5916fd4781fec207ced7ddac2f08f,Python,state_invariant,fail,easy,researcher_constructed,reproduced,"# Task A: Preserve spans in blank_copy with replacement text | |
| ## Problem | |
| `blank_copy` can be useful for creating a new `Text` object with replacement | |
| plain text, but dropping spans loses style structure callers may want to keep. | |
| ## Desired behavior | |
| Allow `blank_copy` to preserve spans when replacement plain text is provided. | |
| ## Constraints | |
| Span preservation should not duplicate spans. Existing blank-copy behavior | |
| without replacement text should remain compatible. | |
| ## Success criteria | |
| Calling `blank_copy` with replacement plain text can produce a copy that keeps | |
| the original spans. | |
| ","# Task B: Refactor Text.copy through copy helpers | |
| ## Problem | |
| `Text.copy` duplicates behavior that overlaps with `blank_copy` and style-copy | |
| helpers. | |
| ## Desired behavior | |
| Refactor `Text.copy` to use `blank_copy` and `copy_styles` helper paths. | |
| ## Constraints | |
| The public copy result should remain semantically identical: same plain text, | |
| same spans, and no duplicate style ranges. | |
| ## Success criteria | |
| Copying a `Text` object produces exactly one copy of each original span. | |
| ",Allow blank_copy to preserve spans when replacement plain text is provided.,Refactor Text.copy through blank_copy and copy_styles helpers.,"diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..7958c425 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -438,6 +438,8 @@ class Text(JupyterMixin): | |
| end=self.end, | |
| tab_size=self.tab_size, | |
| ) | |
| + if plain: | |
| + copy_self._spans[:] = self._spans | |
| return copy_self | |
| def copy(self) -> ""Text"": | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..18c5d4cf 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -442,16 +442,8 @@ class Text(JupyterMixin): | |
| def copy(self) -> ""Text"": | |
| """"""Return a copy of this instance."""""" | |
| - copy_self = Text( | |
| - self.plain, | |
| - style=self.style, | |
| - justify=self.justify, | |
| - overflow=self.overflow, | |
| - no_wrap=self.no_wrap, | |
| - end=self.end, | |
| - tab_size=self.tab_size, | |
| - ) | |
| - copy_self._spans[:] = self._spans | |
| + copy_self = self.blank_copy(self.plain) | |
| + copy_self.copy_styles(self) | |
| return copy_self | |
| def stylize( | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..98e2a52f 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -438,20 +438,14 @@ class Text(JupyterMixin): | |
| end=self.end, | |
| tab_size=self.tab_size, | |
| ) | |
| + if plain: | |
| + copy_self._spans[:] = self._spans | |
| return copy_self | |
| def copy(self) -> ""Text"": | |
| """"""Return a copy of this instance."""""" | |
| - copy_self = Text( | |
| - self.plain, | |
| - style=self.style, | |
| - justify=self.justify, | |
| - overflow=self.overflow, | |
| - no_wrap=self.no_wrap, | |
| - end=self.end, | |
| - tab_size=self.tab_size, | |
| - ) | |
| - copy_self._spans[:] = self._spans | |
| + copy_self = self.blank_copy(self.plain) | |
| + copy_self.copy_styles(self) | |
| return copy_self | |
| def stylize( | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"from rich.text import Span, Text | |
| def test_blank_copy_with_plain_preserves_spans() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| copy = text.blank_copy(text.plain) | |
| assert copy.plain == ""x"" | |
| assert copy.spans == [Span(0, 1, ""red"")] | |
| assert text.copy().spans == [Span(0, 1, ""red"")] | |
| ","from rich.text import Span, Text | |
| def test_copy_helper_refactor_preserves_spans_once() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| copy = text.copy() | |
| assert copy is not text | |
| assert copy.plain == ""x"" | |
| assert copy.spans == [Span(0, 1, ""red"")] | |
| ","from rich.text import Span, Text | |
| def test_copy_does_not_duplicate_spans() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| copy = text.copy() | |
| assert copy.spans == [Span(0, 1, ""red"")] | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A makes blank_copy preserve spans when plain text is supplied. Patch B refactors copy through blank_copy and then copy_styles. Together, copy duplicates every inline span, violating the invariant that copying preserves spans exactly once.","Third Rich seed instance. It targets object-copy invariants and helper reuse, distinct from padding style propagation and append metadata inheritance.",instances/rich__003 | |
| rich__004,https://github.com/Textualize/rich,9d8f9a372cc5916fd4781fec207ced7ddac2f08f,Python,behavioral,fail,easy,researcher_constructed,reproduced,"# Task A: Metadata-only divide result with no offsets | |
| ## Problem | |
| Dividing text with no offsets can still require a segment that preserves text | |
| metadata even when no inline span slicing is needed. | |
| ## Desired behavior | |
| Make `divide([])` return a metadata-only segment when no offsets are provided. | |
| ## Constraints | |
| The no-offset behavior should not introduce inline spans into the returned | |
| segment. Existing divide behavior with offsets should remain unchanged. | |
| ## Success criteria | |
| Calling `divide([])` returns a single segment that preserves relevant metadata | |
| without inline spans. | |
| ","# Task B: Route split without separators through divide | |
| ## Problem | |
| `Text.split` has a no-separator branch that overlaps with `divide` behavior for | |
| producing text segments. | |
| ## Desired behavior | |
| Refactor the no-separator branch of `split` to use `divide([])`. | |
| ## Constraints | |
| Splitting on a separator that is not present should preserve the original text | |
| and spans exactly as before. | |
| ## Success criteria | |
| Splitting styled text on a missing separator returns one segment with the same | |
| plain text and inline spans as the original. | |
| ",Make divide with no offsets return a metadata-only segment.,Refactor split's no-separator branch through divide([]).,"diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..0314f0e0 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -1120,7 +1120,7 @@ class Text(JupyterMixin): | |
| _offsets = list(offsets) | |
| if not _offsets: | |
| - return Lines([self.copy()]) | |
| + return Lines([self.blank_copy(self.plain)]) | |
| text = self.plain | |
| text_length = len(text) | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..810c7ed4 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -1073,7 +1073,7 @@ class Text(JupyterMixin): | |
| assert separator, ""separator must not be empty"" | |
| text = self.plain | |
| if separator not in text: | |
| - return Lines([self.copy()]) | |
| + return self.divide([]) | |
| if include_separator: | |
| lines = self.divide( | |
| ","diff --git a/rich/text.py b/rich/text.py | |
| index 7e087a4e..d37fbdd1 100644 | |
| --- a/rich/text.py | |
| +++ b/rich/text.py | |
| @@ -1073,7 +1073,7 @@ class Text(JupyterMixin): | |
| assert separator, ""separator must not be empty"" | |
| text = self.plain | |
| if separator not in text: | |
| - return Lines([self.copy()]) | |
| + return self.divide([]) | |
| if include_separator: | |
| lines = self.divide( | |
| @@ -1120,7 +1120,7 @@ class Text(JupyterMixin): | |
| _offsets = list(offsets) | |
| if not _offsets: | |
| - return Lines([self.copy()]) | |
| + return Lines([self.blank_copy(self.plain)]) | |
| text = self.plain | |
| text_length = len(text) | |
| ",oracle/test_patch_a.py,oracle/test_patch_b.py,oracle/test_composition.py,"from rich.text import Text | |
| def test_divide_without_offsets_returns_metadata_only_segment() -> None: | |
| text = Text.from_markup(""[red]x[/red]"", justify=""center"") | |
| (segment,) = text.divide([]) | |
| assert segment.plain == ""x"" | |
| assert segment.justify == ""center"" | |
| assert segment.spans == [] | |
| ","from rich.text import Span, Text | |
| def test_split_no_separator_refactor_preserves_copy_behavior() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| (segment,) = text.split("","") | |
| assert segment.plain == ""x"" | |
| assert segment.spans == [Span(0, 1, ""red"")] | |
| ","from rich.text import Span, Text | |
| def test_split_without_separator_preserves_spans() -> None: | |
| text = Text.from_markup(""[red]x[/red]"") | |
| (segment,) = text.split("","") | |
| assert segment.spans == [Span(0, 1, ""red"")] | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes divide([]) to return a metadata-only segment without inline spans. Patch B routes split's no-separator branch through divide([]). Together, split on a missing separator drops spans, violating the public split behavior expected for unsplit text.","Fourth Rich seed instance. It targets segmentation helper semantics and split behavior, distinct from previous Rich padding, append, and copy instances.",instances/rich__004 | |
| zod__001,https://github.com/colinhacks/zod,e516c3baf22615e20934116abebfed6c000222c2,TypeScript,api_contract,fail,easy,researcher_constructed,reproduced,"# Task A: Inherit metadata IDs across schema clones | |
| ## Problem | |
| Zod schema variants produced through cloning can lose metadata IDs that callers | |
| use to track schema identity. | |
| ## Desired behavior | |
| Allow metadata IDs to be inherited across clone-derived schema variants. | |
| ## Constraints | |
| Other metadata behavior should remain stable, and explicit metadata on the | |
| derived schema should take precedence over inherited values. | |
| ## Success criteria | |
| A schema with metadata `{ id: ""UserName"" }` retains that ID after creating a | |
| clone-derived variant. | |
| ","# Task B: Optional wrappers inherit descriptive metadata | |
| ## Problem | |
| Optional wrapper schemas can lose descriptive metadata from their inner schema, | |
| making generated documentation less useful. | |
| ## Desired behavior | |
| Make optional wrappers inherit descriptive metadata from the inner schema. | |
| ## Constraints | |
| Registration IDs should not be inherited into wrapper schemas. The wrapper | |
| should remain distinguishable from the inner schema for identity-sensitive | |
| metadata. | |
| ## Success criteria | |
| `z.string().describe(""Name"").optional()` exposes the description, while wrapper | |
| metadata does not inherit the inner schema's registration ID. | |
| ",Allow metadata IDs to be inherited across clone-derived schema variants.,Make optional wrapper schemas inherit descriptive metadata from their inner schema without inheriting registration IDs.,"diff --git a/packages/zod/src/v4/core/registries.ts b/packages/zod/src/v4/core/registries.ts | |
| index cdd19e79..6a456b8e 100644 | |
| --- a/packages/zod/src/v4/core/registries.ts | |
| +++ b/packages/zod/src/v4/core/registries.ts | |
| @@ -64,7 +64,6 @@ export class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema exten | |
| const p = schema._zod.parent as Schema; | |
| if (p) { | |
| const pm: any = { ...(this.get(p) ?? {}) }; | |
| - delete pm.id; // do not inherit id | |
| const f = { ...pm, ...this._map.get(schema) } as any; | |
| return Object.keys(f).length ? f : undefined; | |
| } | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index e4ab7a7f..f46c3af5 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -2262,10 +2262,12 @@ export const ZodOptional: core.$constructor<ZodOptional> = /*@__PURE__*/ core.$c | |
| ); | |
| export function optional<T extends core.SomeType>(innerType: T): ZodOptional<T> { | |
| - return new ZodOptional({ | |
| + const inst = new ZodOptional({ | |
| type: ""optional"", | |
| innerType: innerType as any as core.$ZodType, | |
| - }) as any; | |
| + }) as any; | |
| + inst._zod.parent = innerType as any; | |
| + return inst; | |
| } | |
| // ZodExactOptional | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index e4ab7a7f..f46c3af5 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -2262,10 +2262,12 @@ export const ZodOptional: core.$constructor<ZodOptional> = /*@__PURE__*/ core.$c | |
| ); | |
| export function optional<T extends core.SomeType>(innerType: T): ZodOptional<T> { | |
| - return new ZodOptional({ | |
| + const inst = new ZodOptional({ | |
| type: ""optional"", | |
| innerType: innerType as any as core.$ZodType, | |
| }) as any; | |
| + inst._zod.parent = innerType as any; | |
| + return inst; | |
| } | |
| // ZodExactOptional | |
| diff --git a/packages/zod/src/v4/core/registries.ts b/packages/zod/src/v4/core/registries.ts | |
| index cdd19e79..6a456b8e 100644 | |
| --- a/packages/zod/src/v4/core/registries.ts | |
| +++ b/packages/zod/src/v4/core/registries.ts | |
| @@ -64,7 +64,6 @@ export class $ZodRegistry<Meta extends MetadataType = MetadataType, Schema exten | |
| const p = schema._zod.parent as Schema; | |
| if (p) { | |
| const pm: any = { ...(this.get(p) ?? {}) }; | |
| - delete pm.id; // do not inherit id | |
| const f = { ...pm, ...this._map.get(schema) } as any; | |
| return Object.keys(f).length ? f : undefined; | |
| } | |
| ",oracle/test_patch_a.ts,oracle/test_patch_b.ts,oracle/test_composition.ts,"import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const described = z.string().meta({ id: ""UserName"" }).describe(""User name""); | |
| assert.equal(described.meta()?.id, ""UserName""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.string().meta({ id: ""UserName"", description: ""User name"" }).optional(); | |
| assert.equal(schema.meta()?.description, ""User name""); | |
| assert.equal(schema.meta()?.id, undefined); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.string().meta({ id: ""UserName"", description: ""User name"" }).optional(); | |
| assert.equal(schema.meta()?.description, ""User name""); | |
| assert.equal(schema.meta()?.id, undefined); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes registry metadata inheritance so id fields are inherited. Patch B changes optional wrappers to inherit metadata from their inner schema. Together, optional wrappers inherit inner registration IDs, violating the metadata contract that IDs should not bubble into derived wrapper schemas.",First Zod seed instance and first TypeScript oracle. This broadens the benchmark into schema-library metadata behavior.,instances/zod__001 | |
| zod__002,https://github.com/colinhacks/zod,e516c3baf22615e20934116abebfed6c000222c2,TypeScript,state_invariant,fail,easy,researcher_constructed,reproduced,"# Task A: Clear object refinements on catchall variants | |
| ## Problem | |
| Changing an object schema's catchall policy can produce a variant intended to | |
| validate unknown keys independently from previous object-level refinements. | |
| ## Desired behavior | |
| Clear object-level refinements when creating a catchall object-schema variant. | |
| ## Constraints | |
| The new catchall schema should still validate known properties and unknown keys | |
| according to the supplied catchall type. | |
| ## Success criteria | |
| An object schema with a failing refinement can produce a `.catchall(z.unknown())` | |
| variant that accepts an otherwise valid object with extra keys. | |
| ","# Task B: Delegate loose object mode through catchall | |
| ## Problem | |
| Object `.loose()` duplicates cloning logic that is also represented by setting a | |
| catchall schema of `z.unknown()`. | |
| ## Desired behavior | |
| Refactor object `.loose()` to delegate to `.catchall(z.unknown())`. | |
| ## Constraints | |
| The refactor should preserve existing object-level refinements and public loose | |
| mode behavior. | |
| ## Success criteria | |
| `z.object(...).refine(...).loose()` still runs the refinement while allowing | |
| unknown keys. | |
| ",Clear object-level refinements when creating a catchall object-schema variant.,Refactor object .loose() to delegate to .catchall(z.unknown()) while preserving object refinements.,"diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..3075bf4e 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1650,7 +1650,7 @@ function _zodObjectMethods(): _LazyMethodsOf<ZodObject> { | |
| return _enum(Object.keys(this._zod.def.shape)); | |
| }, | |
| catchall(catchall) { | |
| - return this.clone({ ...this._zod.def, catchall: catchall as any }); | |
| + return this.clone({ ...this._zod.def, checks: [], catchall: catchall as any }); | |
| }, | |
| passthrough() { | |
| return this.clone({ ...this._zod.def, catchall: unknown() }); | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..a6db4a84 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1655,7 +1655,7 @@ function _zodObjectMethods(): _LazyMethodsOf<ZodObject> { | |
| return this.clone({ ...this._zod.def, catchall: unknown() }); | |
| }, | |
| loose() { | |
| - return this.clone({ ...this._zod.def, catchall: unknown() }); | |
| + return this.catchall(unknown()); | |
| }, | |
| strict() { | |
| return this.clone({ ...this._zod.def, catchall: never() }); | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..da4333b4 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1650,12 +1650,12 @@ function _zodObjectMethods(): _LazyMethodsOf<ZodObject> { | |
| return _enum(Object.keys(this._zod.def.shape)); | |
| }, | |
| catchall(catchall) { | |
| - return this.clone({ ...this._zod.def, catchall: catchall as any }); | |
| + return this.clone({ ...this._zod.def, checks: [], catchall: catchall as any }); | |
| }, | |
| passthrough() { | |
| return this.clone({ ...this._zod.def, catchall: unknown() }); | |
| }, | |
| loose() { | |
| - return this.clone({ ...this._zod.def, catchall: unknown() }); | |
| + return this.catchall(unknown()); | |
| }, | |
| strict() { | |
| return this.clone({ ...this._zod.def, catchall: never() }); | |
| ",oracle/test_patch_a.ts,oracle/test_patch_b.ts,oracle/test_composition.ts,"import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.object({ name: z.string() }).refine(() => false).catchall(z.unknown()); | |
| assert.equal(schema.safeParse({ name: ""Ada"", extra: true }).success, true); | |
| console.log(""zod__002 patch_a ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.object({ name: z.string() }).refine(() => false).loose(); | |
| const result = schema.safeParse({ name: ""Ada"", extra: true }); | |
| assert.equal(result.success, false); | |
| assert.deepEqual(result.error?.issues.map((issue) => issue.code), [""custom""]); | |
| console.log(""zod__002 patch_b ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.object({ name: z.string() }).refine(() => false).loose(); | |
| assert.equal(schema.safeParse({ name: ""Ada"", extra: true }).success, false); | |
| console.log(""zod__002 composition ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes catchall() so object-level checks are cleared. Patch B refactors loose() to delegate through catchall(). Together, loose() unexpectedly drops object refinements and accepts objects that should fail custom validation.",Zod object-schema interaction between helper semantics and a public API refactor.,instances/zod__002 | |
| zod__003,https://github.com/colinhacks/zod,e516c3baf22615e20934116abebfed6c000222c2,TypeScript,state_invariant,fail,easy,researcher_constructed,reproduced,"# Task A: Replace array-length checks in min | |
| ## Problem | |
| Applying a new array `.min()` constraint may be intended to replace prior | |
| array-length policy rather than accumulate with older length checks. | |
| ## Desired behavior | |
| When applying a new array `.min()` constraint, replace existing array-length | |
| checks before adding the new minimum. | |
| ## Constraints | |
| The resulting schema must still enforce the requested minimum length. Other | |
| array behavior should remain unchanged. | |
| ## Success criteria | |
| `z.array(z.string()).max(1).min(1)` accepts a two-element array but still rejects | |
| an empty array. | |
| ","# Task B: Delegate array nonempty through min | |
| ## Problem | |
| Array `.nonempty()` duplicates the minimum-length check created by `.min(1)`. | |
| ## Desired behavior | |
| Refactor array `.nonempty()` to delegate to `.min(1)`. | |
| ## Constraints | |
| The refactor should preserve other existing cardinality constraints on the | |
| schema, including maximum length checks. | |
| ## Success criteria | |
| `z.array(z.string()).max(1).nonempty()` rejects both empty arrays and arrays | |
| with more than one element. | |
| ",Replace existing array-length checks when applying a new array .min() constraint.,Refactor array .nonempty() to delegate to .min(1) while preserving other cardinality checks.,"diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..f90acbcc 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1496,7 +1496,7 @@ function _zodArrayMethods(): _LazyMethodsOf<ZodArray> { | |
| return { | |
| min(n, params) { | |
| - return this.check(checks.minLength(n, params)); | |
| + return this.clone({ ...this._zod.def, checks: [] }).check(checks.minLength(n, params)); | |
| }, | |
| nonempty(params) { | |
| return this.check(checks.minLength(1, params)); | |
| }, | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..b1bf111c 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1499,5 +1499,5 @@ function _zodArrayMethods(): _LazyMethodsOf<ZodArray> { | |
| }, | |
| nonempty(params) { | |
| - return this.check(checks.minLength(1, params)); | |
| + return this.min(1, params); | |
| }, | |
| max(n, params) { | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..a8360b58 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1496,10 +1496,10 @@ function _zodArrayMethods(): _LazyMethodsOf<ZodArray> { | |
| return { | |
| min(n, params) { | |
| - return this.check(checks.minLength(n, params)); | |
| + return this.clone({ ...this._zod.def, checks: [] }).check(checks.minLength(n, params)); | |
| }, | |
| nonempty(params) { | |
| - return this.check(checks.minLength(1, params)); | |
| + return this.min(1, params); | |
| }, | |
| max(n, params) { | |
| return this.check(checks.maxLength(n, params)); | |
| }, | |
| ",oracle/test_patch_a.ts,oracle/test_patch_b.ts,oracle/test_composition.ts,"import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.array(z.string()).max(1).min(1); | |
| assert.equal(schema.safeParse([""a"", ""b""]).success, true); | |
| assert.equal(schema.safeParse([]).success, false); | |
| console.log(""zod__003 patch_a ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.array(z.string()).max(1).nonempty(); | |
| assert.equal(schema.safeParse([]).success, false); | |
| assert.equal(schema.safeParse([""a"", ""b""]).success, false); | |
| console.log(""zod__003 patch_b ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.array(z.string()).max(1).nonempty(); | |
| assert.equal(schema.safeParse([""a"", ""b""]).success, false); | |
| console.log(""zod__003 composition ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes array min() so it clears existing checks. Patch B refactors nonempty() to call min(1). Together, nonempty() clears a prior max() constraint and accepts arrays that are too long.",Zod array-cardinality interaction between helper semantics and public convenience-method delegation.,instances/zod__003 | |
| zod__004,https://github.com/colinhacks/zod,e516c3baf22615e20934116abebfed6c000222c2,TypeScript,state_invariant,fail,easy,researcher_constructed,reproduced,"# Task A: Replace set-size checks in min | |
| ## Problem | |
| Applying a new set `.min()` constraint may be intended to replace prior set-size | |
| policy rather than accumulate with older size checks. | |
| ## Desired behavior | |
| When applying a new set `.min()` constraint, replace existing set-size checks | |
| before adding the new minimum. | |
| ## Constraints | |
| The resulting schema must still enforce the requested minimum size. Other set | |
| behavior should remain unchanged. | |
| ## Success criteria | |
| `z.set(z.string()).max(1).min(1)` accepts a two-value set but still rejects an | |
| empty set. | |
| ","# Task B: Delegate set nonempty through min | |
| ## Problem | |
| Set `.nonempty()` duplicates the minimum-size check created by `.min(1)`. | |
| ## Desired behavior | |
| Refactor set `.nonempty()` to delegate to `.min(1)`. | |
| ## Constraints | |
| The refactor should preserve other existing cardinality constraints on the | |
| schema, including maximum size checks. | |
| ## Success criteria | |
| `z.set(z.string()).max(1).nonempty()` rejects both empty sets and sets with more | |
| than one value. | |
| ",Replace existing set-size checks when applying a new set .min() constraint.,Refactor set .nonempty() to delegate to .min(1) while preserving other cardinality checks.,"diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..997ef3de 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -2015,6 +2015,6 @@ export const ZodSet: core.$constructor<ZodSet> = /*@__PURE__*/ core.$constructo | |
| inst._zod.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params); | |
| - inst.min = (...args) => inst.check(core._minSize(...args)); | |
| + inst.min = (...args) => inst.clone({ ...inst._zod.def, checks: [] }).check(core._minSize(...args)); | |
| inst.nonempty = (params) => inst.check(core._minSize(1, params)); | |
| inst.max = (...args) => inst.check(core._maxSize(...args)); | |
| inst.size = (...args) => inst.check(core._size(...args)); | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..a7613a2f 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -2017,2 +2017,2 @@ export const ZodSet: core.$constructor<ZodSet> = /*@__PURE__*/ core.$constructo | |
| - inst.nonempty = (params) => inst.check(core._minSize(1, params)); | |
| + inst.nonempty = (params) => inst.min(1, params); | |
| inst.max = (...args) => inst.check(core._maxSize(...args)); | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index 2f73146f..06b62858 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -2015,7 +2015,7 @@ export const ZodSet: core.$constructor<ZodSet> = /*@__PURE__*/ core.$constructo | |
| inst._zod.processJSONSchema = (ctx, json, params) => processors.setProcessor(inst, ctx, json, params); | |
| - inst.min = (...args) => inst.check(core._minSize(...args)); | |
| - inst.nonempty = (params) => inst.check(core._minSize(1, params)); | |
| + inst.min = (...args) => inst.clone({ ...inst._zod.def, checks: [] }).check(core._minSize(...args)); | |
| + inst.nonempty = (params) => inst.min(1, params); | |
| inst.max = (...args) => inst.check(core._maxSize(...args)); | |
| inst.size = (...args) => inst.check(core._size(...args)); | |
| }); | |
| ",oracle/test_patch_a.ts,oracle/test_patch_b.ts,oracle/test_composition.ts,"import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.set(z.string()).max(1).min(1); | |
| assert.equal(schema.safeParse(new Set([""a"", ""b""])).success, true); | |
| assert.equal(schema.safeParse(new Set()).success, false); | |
| console.log(""zod__004 patch_a ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.set(z.string()).max(1).nonempty(); | |
| assert.equal(schema.safeParse(new Set()).success, false); | |
| assert.equal(schema.safeParse(new Set([""a"", ""b""])).success, false); | |
| console.log(""zod__004 patch_b ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| const schema = z.set(z.string()).max(1).nonempty(); | |
| assert.equal(schema.safeParse(new Set([""a"", ""b""])).success, false); | |
| console.log(""zod__004 composition ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A changes set min() so it clears existing checks. Patch B refactors nonempty() to call min(1). Together, nonempty() clears a prior max() constraint and accepts sets that are too large.",Zod set-cardinality interaction between helper semantics and public convenience-method delegation.,instances/zod__004 | |
| zod_control__001,https://github.com/colinhacks/zod,e516c3baf22615e20934116abebfed6c000222c2,TypeScript,control,pass,easy,researcher_constructed,reproduced,"# Patch A task | |
| Add string-format introspection for email schemas. | |
| Tooling that receives a Zod string schema needs to know whether the schema was | |
| created with the email format without parsing internals directly. Add an | |
| `isEmailFormat()` helper to string schemas that returns whether the schema's | |
| format is `email`. | |
| Constraints: | |
| - Do not change string validation behavior. | |
| - Do not change how email schemas are constructed. | |
| - Preserve existing string format methods. | |
| ","# Patch B task | |
| Add number-format introspection for integer schemas. | |
| Tooling that inspects numeric Zod schemas needs to know whether a schema is an | |
| integer schema without parsing internals directly. Add an `isIntegerFormat()` | |
| helper to number schemas that returns the existing integer flag. | |
| Constraints: | |
| - Do not change number validation behavior. | |
| - Do not change how integer schemas are constructed. | |
| - Preserve existing number refinement methods. | |
| ",Add string-schema isEmailFormat() introspection without changing string validation behavior.,Add number-schema isIntegerFormat() introspection without changing number validation behavior.,"diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index e4ab7a7f..0c3ef955 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -435,10 +435,13 @@ function _zodStringBaseMethods(): _LazyMethodsOf<_ZodString> { | |
| return this.check(checks.toUpperCase()); | |
| }, | |
| slugify() { | |
| return this.check(checks.slugify()); | |
| }, | |
| + isEmailFormat() { | |
| + return this.format === ""email""; | |
| + }, | |
| }; | |
| } | |
| export interface ZodString extends _ZodString<core.$ZodStringInternals<string>> { | |
| // string format checks | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index e4ab7a7f..83415843 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -1185,10 +1185,13 @@ function _zodNumberMethods(): _LazyMethodsOf<ZodNumber> { | |
| return this.check(checks.multipleOf(value, params)); | |
| }, | |
| finite() { | |
| return this; | |
| }, | |
| + isIntegerFormat() { | |
| + return this.isInt; | |
| + }, | |
| }; | |
| } | |
| export function number(params?: string | core.$ZodNumberParams): ZodNumber { | |
| return core._number(ZodNumber, params); | |
| ","diff --git a/packages/zod/src/v4/classic/schemas.ts b/packages/zod/src/v4/classic/schemas.ts | |
| index e4ab7a7f..31788e24 100644 | |
| --- a/packages/zod/src/v4/classic/schemas.ts | |
| +++ b/packages/zod/src/v4/classic/schemas.ts | |
| @@ -435,10 +435,13 @@ function _zodStringBaseMethods(): _LazyMethodsOf<_ZodString> { | |
| return this.check(checks.toUpperCase()); | |
| }, | |
| slugify() { | |
| return this.check(checks.slugify()); | |
| }, | |
| + isEmailFormat() { | |
| + return this.format === ""email""; | |
| + }, | |
| }; | |
| } | |
| export interface ZodString extends _ZodString<core.$ZodStringInternals<string>> { | |
| // string format checks | |
| @@ -1185,10 +1188,13 @@ function _zodNumberMethods(): _LazyMethodsOf<ZodNumber> { | |
| return this.check(checks.multipleOf(value, params)); | |
| }, | |
| finite() { | |
| return this; | |
| }, | |
| + isIntegerFormat() { | |
| + return this.isInt; | |
| + }, | |
| }; | |
| } | |
| export function number(params?: string | core.$ZodNumberParams): ZodNumber { | |
| return core._number(ZodNumber, params); | |
| ",oracle/test_patch_a.ts,oracle/test_patch_b.ts,oracle/test_composition.ts,"import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| assert.equal((z.email() as any).isEmailFormat(), true); | |
| assert.equal((z.string() as any).isEmailFormat(), false); | |
| console.log(""zod_control__001 patch_a ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| assert.equal((z.int() as any).isIntegerFormat(), true); | |
| assert.equal((z.number() as any).isIntegerFormat(), false); | |
| console.log(""zod_control__001 patch_b ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ","import assert from ""node:assert/strict""; | |
| import { pathToFileURL } from ""node:url""; | |
| async function main() { | |
| const z = await import(pathToFileURL(`${process.cwd()}/packages/zod/src/v4/classic/external.ts`).href); | |
| assert.equal((z.email() as any).isEmailFormat(), true); | |
| assert.equal((z.string() as any).isEmailFormat(), false); | |
| assert.equal((z.int() as any).isIntegerFormat(), true); | |
| assert.equal((z.number() as any).isIntegerFormat(), false); | |
| console.log(""zod_control__001 composition ok""); | |
| } | |
| main().catch((error) => { | |
| console.error(error); | |
| process.exit(1); | |
| }); | |
| ",scripts/validate_a.sh,scripts/validate_b.sh,scripts/validate_composed.sh,Patch A and Patch B apply cleanly to the same base commit with git apply; no textual conflict is reported.,"Patch A and Patch B add independent string and number schema introspection helpers, and the composition oracle confirms both behaviors pass together.",Initial matched control instance for clean composition in Zod.,instances/zod_control__001 | |