Skip to content

Commit 2d460fd

Browse files
fix(safeoutputs): fix upload-pipeline-artifact 405 by adding scopeIdentifier to container API requests (#421)
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/b392de53-ecf2-45c9-a6a4-b7f9f496f1fd Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
1 parent aa31e18 commit 2d460fd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/safeoutputs/upload_pipeline_artifact.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,20 @@ impl Executor for UploadPipelineArtifactResult {
404404
.unwrap_or(&self.staged_file);
405405

406406
// ── Step 1: Create container ─────────────────────────────────────
407+
// The `scopeIdentifier` query parameter (project GUID) is required for
408+
// the POST to route correctly in ADO. Omitting it causes a 405 because
409+
// the unscoped `_apis/resources/containers` collection does not support
410+
// POST. The body only needs the container name; the project scope must
411+
// be in the query string.
407412
let container_url = format!(
408-
"{}/_apis/resources/containers?api-version=7.1-preview.4",
413+
"{}/_apis/resources/containers?scopeIdentifier={}&api-version=7.1-preview.4",
409414
org_url.trim_end_matches('/'),
415+
utf8_percent_encode(project_id, PATH_SEGMENT),
410416
);
411417
debug!("Creating container for artifact '{}': {}", final_name, container_url);
412418

413419
let container_body = serde_json::json!({
414420
"name": final_name,
415-
"scope": project_id,
416421
});
417422
let container_resp = client
418423
.post(&container_url)
@@ -445,8 +450,9 @@ impl Executor for UploadPipelineArtifactResult {
445450
debug!("Container created: id={}", container_id);
446451

447452
// ── Step 2: Upload file to container ─────────────────────────────
453+
// Use `scopeIdentifier` (not `scope`) to match the ADO containers API.
448454
let upload_url = format!(
449-
"{}/_apis/resources/containers/{}?itemPath={}/{}&scope={}&api-version=7.1-preview.4",
455+
"{}/_apis/resources/containers/{}?itemPath={}/{}&scopeIdentifier={}&api-version=7.1-preview.4",
450456
org_url.trim_end_matches('/'),
451457
container_id,
452458
utf8_percent_encode(&final_name, PATH_SEGMENT),

0 commit comments

Comments
 (0)