Skip to content

Azure DevOps: az reads a local file when a pull request title or description looks like @path #37098

Closed

Description

@Tabonx

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/source-control-azure-devops

Steps to reproduce

az expands file references in every argument before it parses the command (_expand_file_prefixed_files in azure/cli/core/commands/__init__.py, azure-cli 2.90.0). An argument is replaced by the contents of a file when it starts with @, or when the text after its first = starts with @. A path that does not exist is left as written. azure-cli has no escape for this.

T3 Code passes free text to az inline:

  • AzureDevOpsCli.createPullRequest passes the generated title as --title <title>.
  • AzureDevOpsPullRequestCli.updatePullRequest passes --title=<title> and --description=<body>.
  • createPullRequest passes the source branch as written, and git accepts a branch named @name.
  1. In an Azure DevOps checkout, create a file notes.txt that contains from the file.
  2. Edit an open pull request in T3 Code and set its title to @notes.txt.

Expected behavior

The pull request title on Azure DevOps is @notes.txt.

Actual behavior

The title is from the file. A title such as [email protected] gives a=from the file.

Proposed fix

  1. One check before every az run. All 19 az calls go through AzureDevOpsCli.execute. It refuses, before spawning, any argument that az would expand: one that starts with @, or whose text after the first = starts with @. A new call site that forgets the rule then fails in a test instead of reading a file.
  2. Free text travels in files. A small helper in AzureDevOpsCli writes a value to a temporary file, returns --title @<file> style arguments that the check lets through, and removes the file afterwards. createPullRequest already sends the description this way (@${bodyFile}); title and the updatePullRequest fields use the same helper. az does not expand the file's contents again.
  3. Branches as full refs. createPullRequest passes refs/heads/<name> for the source and target branch. az accepts full refs, so no branch value starts with @. listPullRequests already percent-encodes the branch, which turns @ into %40.

Not proposed: refusing titles that start with @ (a title like @team please review is fine once it goes through a file), moving the calls to az devops invoke, or an escape character (az has none).

Tests

  • AzureDevOpsCli.test.ts: execute refuses ["--title", "@x"], ["--title=@x"] and ["--title", "a=@x"] and spawns nothing.
  • AzureDevOpsPullRequestCli.test.ts: updatePullRequest with the title @notes.txt passes a file whose content is exactly @notes.txt. The existing case at line 446 that expects --description=- rewrote the page... changes with it.

Impact

Minor bug or occasional failure

Version or commit

main at 2cb2fa1, azure-cli 2.90.0

Activity

  1. added 2 commits that reference this issue on Nov 15, 2026
    8847eaf
    b44299b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions