Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Summary

Custom command-line parameters currently propagate to all projects in a Rush command, causing cache invalidation even when parameters don't affect specific operations. This PR adds parameterNamesToIgnore to rush-project.json to exclude irrelevant parameters from cache key calculation and command invocation.

Fixes #5432

Details

Schema & Interface

  • Added parameterNamesToIgnore?: string[] to IOperationSettings in rush-project.json
  • Field accepts parameter longName values (e.g., --production, --verbose)

Core Logic

  • Refactored getCustomParameterValuesByPhasegetCustomParameterValuesByOperation
  • Returns { parameterValues, ignoredParameterValues } for filtered parameters and logging
  • Filters parameters by checking operation.settings.parameterNamesToIgnore against parameter longName
  • Uses appendToArgList for both included and ignored parameters to get actual CLI values
  • Returns arrays instead of Sets to allow duplicate arguments

Runners

  • ShellOperationRunner and IPCOperationRunner accept ignoredParameterValues
  • Log ignored parameters via terminal.writeLine() before invocation with clear message indicating project-level configuration

Plugins

  • IPCOperationRunnerPlugin uses new getCustomParameterValuesByOperation function
  • ShardedPhaseOperationPlugin derives ignored values from operation settings for both collator and shard operations

Parameter Parsing Helpers

  • Created cli/parsing/defineCustomParameters.ts helper that accepts a target map to avoid copying
  • Map is keyed by IParameterJson for consistency
  • Created companion cli/parsing/associateParametersByPhase.ts helper extracted from PhasedScriptAction
  • Refactored BaseScriptAction and PhasedScriptAction to use shared helpers
  • Both helpers are used in comprehensive unit tests

Configuration Example

{
  "operationSettings": [
    {
      "operationName": "_phase:build",
      "parameterNamesToIgnore": ["--production"]
    }
  ]
}

The --production parameter will be excluded from command invocation and cache key for this operation, preventing cache breaks when the parameter changes but doesn't affect the build output.

How it was tested

  • Added comprehensive unit tests with all parameter types (flag, string, choice, stringList)
  • Created test repository configurations where each parameter type is filtered in at least one operation
  • Tests use CommandLineParser.executeWithoutErrorHandlingAsync() to properly parse parameter values through the standard parsing flow
  • Verified that parameters are correctly filtered based on parameterNamesToIgnore configuration
  • All existing tests pass (503 tests)
  • Manual verification that ignored parameters are properly logged

Impacted documentation

Original prompt

This section details on the original issue you should resolve

<issue_title>[rush] Feature Request - Allow project-level ignoring of custom command-line parameters</issue_title>
<issue_description>## Summary
Currently support for custom parameters in command-line.json is all-or-nothing with respect to which projects they get forwarded to. Which phases they get forwarded to is configurable, however.

Since the exact CLI is used as part of the cache key for the build cache (and propagates into downstream operations since they include the cache keys of their dependencies), this means that if you have a CLI parameter (e.g. --production) that has no effect on a given project, adding or removing the parameter will cause a cache break without providing any value.

We should allow projects to mark (via rush-project.json) that for a given operation, certain custom command-line parameters should be discarded when deriving the CLI.

Details

Add a new field parameterNamesToIgnore (name negotiable) in the operationSettings sub-objects in rush-project.json that is an array of the parameterLongName values defined in command-line.json.

When expanding the command line arguments to be passed to ShellOperationRunner, any custom parameters that match the parameterNamesToIgnore entry for the operation should be discarded. We emit a verbose log line alongside the "Invoking ..." log that remarks on any parameters that were ignored.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.162.0
rushVersion from rush.json? 5.162.0
useWorkspaces from rush.json? Yes
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? 22.16.0
</issue_description>

<agent_instructions>The getCustomParameterValuesByPhase helper in ShellOperationRunnerPlugin will need to be updated to instead be getCustomParameterValuesForOperation and take in the full Operation instance so that it can access the operationSettings object and filter out any ignored parameters. It should also return both the serialized parameter values and an array of the ignored parameter values, since the latter will be used for logging.
The internal state map for this helper should collate a Set instead of precalculating the flattened array.

ShellOperationRunner and IPCOperationRunner should both accept the ignoredParameterValues property so that they can log it during startup.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 6, 2025 20:02
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add project-level ignoring for custom command-line parameters Add project-level parameter ignoring to prevent unnecessary cache invalidation Nov 6, 2025
Copilot finished work on behalf of dmichon-msft November 6, 2025 20:27
Copilot AI requested a review from dmichon-msft November 6, 2025 20:27
@dmichon-msft
Copy link
Contributor

@copilot address feedback

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI changed the title Add project-level parameter ignoring to prevent unnecessary cache invalidation [rush] Add project-level parameter ignoring to prevent unnecessary cache invalidation Nov 7, 2025
Copilot AI requested a review from dmichon-msft November 7, 2025 22:43
Copilot finished work on behalf of dmichon-msft November 7, 2025 22:43
Copy link
Contributor

@dmichon-msft dmichon-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Follow the provided guidance for how to properly unit test the ignoring of command line parameters.

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI requested a review from dmichon-msft November 7, 2025 23:59
Copilot finished work on behalf of dmichon-msft November 7, 2025 23:59
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot finished work on behalf of dmichon-msft November 12, 2025 01:51
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Copilot AI requested a review from dmichon-msft November 12, 2025 19:23
Copilot finished work on behalf of dmichon-msft November 12, 2025 19:23
@iclanton
Copy link
Member

@copilot Run rush change --no-fetch --bulk --bump-type minor --message "<DESCRIBE THE CHANGE HERE>" to generate the necessary change file. Make sure you replace <DESCRIBE THE CHANGE HERE> with a description of this change which will show up in the changelog when this is published.

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot Run rush change --no-fetch --bulk --bump-type minor --message "<DESCRIBE THE CHANGE HERE>" to generate the necessary change file. Make sure you replace <DESCRIBE THE CHANGE HERE> with a d...

Generated change file in commit 4063f98.

Copilot AI requested a review from iclanton November 13, 2025 00:19
Copilot finished work on behalf of iclanton November 13, 2025 00:19
Copy link
Contributor

@dmichon-msft dmichon-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor touchup to the change file remaining

@dmichon-msft dmichon-msft marked this pull request as ready for review November 13, 2025 01:59
Copy link
Member

@D4N14L D4N14L left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took a lot more wiring in than I would have thought... maybe an argument for discussing changes here, but certainly not for this PR.

@dmichon-msft dmichon-msft merged commit 817e924 into main Nov 13, 2025
8 checks passed
@dmichon-msft dmichon-msft deleted the copilot/add-project-level-parameter-ignoring branch November 13, 2025 19:45
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Nov 13, 2025
iclanton added a commit that referenced this pull request Nov 19, 2025
…ion-test (#5456)

* [rush-lib] fix bridge package command (#5411)

* rush change

* fix: enable prerelease version matching in bridge-package command

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Introduce an ESLint rule to coalesce imports. (#5414)

* Use the no-duplicate-imports rule.

* fixup! Use the no-duplicate-imports rule.

* fixup! Use the no-duplicate-imports rule.

* Fix duplicate import issues.

* Use the import/no-duplicates rule.

* Manual fixes.

* [eslint-plugin] Document the @rushstack/typedef-var rule and clarify scope (#5410)

* docs(eslint-plugin): document the @rushstack/typedef-var rule

* chore(changefile): add changefile for typedef-var documentation

* docs: remove for...of and for...in exception from typedef-var rule documentation

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decpouled local dependencies. (#5415)

* [heft-rspack-plugin] Initial implementation of a Rspack Heft plugin. (#4015)

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [rush] Fork npm-check into rush-lib (#5416)

* Fork npm-check

* rush update

* Update test scripts in package json

* rush update

* Fix test file

* Add and update readmes

* Update readme, update config

* Update readme

---------

Co-authored-by: cmalonzo <cmalonzo@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Fix an issue with the return type of Executable.waitForExitAsync. (#5417)

* Clean up the `repo-scripts bump-decoupled-local-dependencies` action. (#5418)

* Move files around in repo-toolbox.

* Don't bump allowed alternative dependencies.

* Include @rushstack/set-webpack-public-path-plugin@^4.1.16 in common-versions.json.

* [eslint-plugin] Introduce `@rushstack/import-requires-chunk-name` and `@rushstack/pair-react-dom-render-unmount` rules. (#5419)

* Include the @rushstack/import-requires-chunk-name rule.

* Include the @rushstack/pair-react-dom-render-unmount rule.

* fixup! Include the @rushstack/pair-react-dom-render-unmount rule.

* Include missing documentation.

* Rush change.

* Sort README entries.

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Extract CredentialCache from Rush into @rushstack/credential-cache (#5421)

* Add new credential-cache package

* Add test command

* Factor out CredentialCache

* Fix routing

* Fix API

* Update readme

* Update readme

* rush update

* Forward rush-user folder name

* Remove old credentials schema

* Restore caching in getHomeFolder

* Remove reexport of areDeepEqual

* Update API md

* Centralize polyfill

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Fix an issue where suppressed rule violations still show up in the report in ESLint >=9.37.0. (#5422)

* Fix an issue where suppressed rule violations still show up in the report in ESLint >=9.37.0.

* Fix an issue where the ESLint process will crash when running in the ESLint VSCode extension in ESLint >=9.37.0.

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decoupled local dependencies. (#5420)

* [heft-lint] Fix TypeScript program passing (#5428)

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* [API Extractor] Add support for printing a diff of changed API reports in non-local builds. (#5427)

* Fix an issue where verbose API extractor messages may not be passed to the Heft plugin.

* Add diff printing to API Extractor's report issue logging.

* Expose an alwaysShowChangedApiReportDiffOnNonLocalBuild option in the api-extractor-heft-plugin configuration file.

* Use the alwaysShowChangedApiReportDiffOnNonLocalBuild in the local rig

* fixup! Add diff printing to API Extractor's report issue logging.

* Generate a JSON schemas artifact after publish. (#5429)

* Copy JSON schemas to projects' temp/json-schemas folders.

* Introduce a tool for collecting JSON schemas.

* Record JSON schemas during publish.

* Produce artifacts during CI.

* Fix publish. (#5430)

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [heft-node-rig] Add lib-dts and lib-esm to cleanFiles glob (#5438)

* Initial plan

* Add lib-dts and lib-esm to cleanFiles in heft-node-rig

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Add change file for heft-node-rig

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [eslint-plugin] Fix no-external-local-imports in editor (#5441)

* [eslint-plugin] Fix calculation of project folder in ESLint
* [heft-lint] Set parserOptions.tsconfigRootDir

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* Bump decoupled local dependencies. (#5440)

* Bump cyclic dependencies.

* Bump TSDoc dependencies.

* Rush update.

* [devx] Apply schemas to Rush/Heft config files in VS Code, add clean build launch config (#5445)

* Bind schemas in vscode

* Add clean build launch config

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* [heft-typescript] Support `${configDir}` token in tsconfig.json (#5444)

* Support ${configDir} in typescript file copier

* Use ${configDir} in local rigs

* Use const

* Fix a TSDoc link.

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [lint] Ensure correctness of SARIF output logs (#5443)

* [eslint-bulk] Report bulk suppressions as suppressions

* [heft-lint] Include suppressed results

* Enable sarif log for local rigs, add test

* Fix lint cache

* Fix typo in TSLint

---------

Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>

* Update changelogs [skip ci]

* Bump versions [skip ci]

* [rush] Add project-level parameter ignoring to prevent unnecessary cache invalidation (#5433)

* Initial plan

* Add parameter ignoring feature to rush-lib

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Add tests for parameter ignoring feature

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Refactor to eliminate code duplication in parameter collection

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Improve documentation and add clarifying comments

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Address PR feedback: use ignoredParameterValues and improve filtering

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Address final PR feedback: improve logging and test coverage

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Centralize parameter creation helper and share with BaseScriptAction

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Ensure all parameter types are tested for filtering

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Refactor parameter helpers into cli/parsing directory

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Use CommandLineParser to parse parameter values in test

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Use executeWithoutErrorHandlingAsync instead of executeAsync

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Add rush change file for project-level parameter ignoring feature

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Adjust formatting of change file

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Co-authored-by: David Michon <dmichon@microsoft.com>

* [rush-lib] Add validation for parameterNamesToIgnore in rush-project.json (#5448)

* Initial plan

* Add validation for parameterNamesToIgnore in rush-project.json

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Remove unused test repository

* Address PR feedback: combine error messages and add malformed parameter test

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Add changelog entry for rush-lib

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Add tests for parameter validation with valid parameters

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Update libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts

Co-authored-by: David Michon <dmichon@microsoft.com>

* Update common/changes/@microsoft/rush-lib/copilot-validate-parameter-names-to-ignore_2025-11-13-23-26.json

* Fix changelog entry to use @microsoft/rush package name

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
Co-authored-by: David Michon <dmichon@microsoft.com>

* [rush-lib] Add PathProjectSelectorParser with path: scheme and auto-routing (#5451)

* Initial plan

* Add PathProjectSelectorParser implementation with path: scheme

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Address code review feedback and add comprehensive unit tests for selector parsers

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Add tests for VersionPolicyProjectSelectorParser and SubspaceSelectorParser

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Refactor tests into separate files and improve PathProjectSelectorParser testability

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Add change file for PathProjectSelectorParser feature

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Update common/changes/@microsoft/rush/copilot-add-path-project-selector-parser_2025-11-17-22-30.json

* Address code review feedback: make workingDirectory required and add comprehensive tests

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Fix Windows path separator issue by normalizing to forward slashes for LookupByPath

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Use consistent cwd from RushCommandLineParser for path resolution

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

* Auto-route relative and absolute POSIX paths to path: selector

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Use Path.convertToSlashes helper instead of manual path separator conversion

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>

* Rush change.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: David Michon <dmichon@microsoft.com>
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>

* Initial plan

* Generate changelogs for webpack version bump

Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>

---------

Co-authored-by: Lincoln <778157949@qq.com>
Co-authored-by: Rushbot <rushbot@users.noreply.github.com>
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
Co-authored-by: yuza🍊 <yuji.min.dev@gmail.com>
Co-authored-by: Camille Malonzo <cmalonzo@microsoft.com>
Co-authored-by: cmalonzo <cmalonzo@users.noreply.github.com>
Co-authored-by: David Michon <dmichon@microsoft.com>
Co-authored-by: David Michon <dmichon-msft@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[rush] Feature Request - Allow project-level ignoring of custom command-line parameters

4 participants