Skip to content

fix(azure-devops): use absolute URL and compound repository ID in pipeline permit action - #8181

Merged
awanlin merged 1 commit into
backstage:mainfrom
artificialvirus:fix/pipeline-permit-url-and-repo-id
Apr 11, 2026
Merged

fix(azure-devops): use absolute URL and compound repository ID in pipeline permit action#8181
awanlin merged 1 commit into
backstage:mainfrom
artificialvirus:fix/pipeline-permit-url-and-repo-id

Conversation

@artificialvirus

Copy link
Copy Markdown
Contributor

Hey, I just made a Pull Request!

Bug Fix: azure:pipeline:permit action — two issues resolved

Bug 1: Relative URL causes ECONNREFUSED

The azure:pipeline:permit action constructs a request URL as a relative path:

// Before (broken)
const requestUrl = `${project}/_apis/pipelines/pipelinepermissions/${resourceType}/${resourceId}?api-version=${apiVersion}`;

When passed to HttpClient.patch(), this relative URL resolves to http://localhost:80/... instead of the intended Azure DevOps API endpoint, causing ECONNREFUSED errors.

Fix: Prefix the URL with the full Azure DevOps base URL (${url}/):

// After (fixed)
const requestUrl = `${url}/${project}/_apis/pipelines/pipelinepermissions/${resourceType}/${resolvedResourceId}?api-version=${apiVersion}`;

Bug 2: Repository resources require compound resource ID

The Azure DevOps Pipeline Permissions API requires repository resource IDs in the compound format {projectId}.{repositoryId}. Passing only the repository GUID results in 400 Bad Request — "Invalid resource id".

Fix: For resourceType === 'repository', automatically resolve the project GUID via the Core API and construct the compound ID. If the provided resourceId already contains a dot (i.e., the caller already provided a compound ID), it is passed through unchanged.

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes) — N/A (backend-only change)
  • All your commits have a Signed-off-by line in the message. (more info)

Test coverage (8 tests, all passing)

Test Purpose
no credentials Error path — throws when no token or integration configured
token auth + endpoint Happy path with absolute URL
repository type Verifies compound ID auto-resolution ({projectId}.{repositoryId})
request failure Error propagation from HTTP client
NEW: compound repo ID Verifies getCoreApi().getProject() called, compound ID constructed
NEW: dot passthrough Repository ID already containing . skips resolution
NEW: non-repo type getCoreApi NOT called for endpoint/variablegroup types
NEW: project lookup failure Throws InputError when project not found

Files changed (3 files, +142 / -4)

  • plugins/scaffolder-backend-module-azure-devops/src/actions/devopsPermitPipeline.ts — Both fixes
  • plugins/scaffolder-backend-module-azure-devops/src/actions/devopsPermitPipeline.test.ts — Updated + 4 new tests
  • .changeset/fix-pipeline-permit-url-and-repo-id.md — Patch changeset

…eline permit action

The azure:pipeline:permit action passed a relative URL to HttpClient.patch(),
which resolved to localhost:80 causing ECONNREFUSED errors. Fixed by prefixing
the request URL with the full Azure DevOps base URL.

For repository resource types, the Azure DevOps Pipeline Permissions API requires
a compound resource ID in {projectId}.{repositoryId} format. Added automatic
resolution via the Core API when the provided resourceId does not already contain
a dot separator.

Signed-off-by: AlperOnder <alperonder980@gmail.com>
@backstage-goalie

Copy link
Copy Markdown
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-scaffolder-backend-module-azure-devops workspaces/azure-devops/plugins/scaffolder-backend-module-azure-devops patch v0.22.1

@awanlin

awanlin commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Hi @EsmerlinJM, as the initial author of this action can you give this PR a quick look, please?

@awanlin

awanlin commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

HI @artificialvirus, thanks for the contribution, I'm away at BackstageCon/KubeCon this week and won't have time to review this for a bit, if I have time it will be this Friday if not it won't be till the Friday after. Just wanted to give you a heads up. I also asked the initial author of this action to review as well. 👍

@awanlin awanlin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry this took as long as it did to review @artificialvirus, let's ship it 🚀

@awanlin
awanlin merged commit c6820af into backstage:main Apr 11, 2026
12 checks passed
evanlankveld pushed a commit to evanlankveld/community-plugins that referenced this pull request Apr 28, 2026
…eline permit action (backstage#8181)

The azure:pipeline:permit action passed a relative URL to HttpClient.patch(),
which resolved to localhost:80 causing ECONNREFUSED errors. Fixed by prefixing
the request URL with the full Azure DevOps base URL.

For repository resource types, the Azure DevOps Pipeline Permissions API requires
a compound resource ID in {projectId}.{repositoryId} format. Added automatic
resolution via the Core API when the provided resourceId does not already contain
a dot separator.

Signed-off-by: AlperOnder <alperonder980@gmail.com>
Signed-off-by: Emiel van Lankveld <evanlankveld@bol.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants