Skip to content

Fix job attachment 401s for submitted jobs - #773

Draft
v-elegacheva wants to merge 8 commits into
microsoft:mainfrom
v-elegacheva:ekaterina/sdk-job-update-e2e
Draft

v-elegacheva wants to merge 8 commits into
microsoft:mainfrom
v-elegacheva:ekaterina/sdk-job-update-e2e

Conversation

@v-elegacheva

@v-elegacheva v-elegacheva commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes job attachment operations failing with 401 ClientAuthenticationError after submission.

upload_attachment, download_attachment, and list_attachments now fetch a fresh SAS-signed URI for the job's actual linked container instead of reusing the unsigned details.container_uri. Custom container names and explicit container URI overrides remain supported.

Testing

  • Added regression coverage for upload, list, and download with unsigned job details.
  • Added coverage for custom container names and explicit URI overrides.
  • Full suite: 108 passed, 18 skipped.
  • Verified clean compatibility with Update autogenerated client #772: the combined suite passes, and Update autogenerated client #772 supplies the generated /jobs/{jobId} update route.

Related

The generated job-update endpoint correction is intentionally left to #772, which regenerates the complete client rather than hand-editing generated code.

- upload_attachment, download_attachment, and list_attachments in base_job.py were reusing the unsigned container_uri returned by job creation instead of always fetching a fresh SAS-signed URI via workspace.get_container_uri(), causing 401 NoAuthenticationInformation errors.
- build_services_jobs_update_request in the generated _operations.py used the wrong URL path segment 'jobUpdateOptions' (the request model type name) instead of 'jobs', causing workspace.update_job() to fail with 404 Not Found.
@v-elegacheva
v-elegacheva requested a review from a team as a code owner September 18, 2026 00:00
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@v-elegacheva
v-elegacheva marked this pull request as draft September 18, 2026 17:45
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI 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.

🟡 Changes recommended

Attachment methods now target the wrong container for jobs created with a custom container name.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Fixes attachment authentication failures and the incorrect job-update endpoint.

Changes:

  • Refreshes SAS-signed attachment container URIs.
  • Corrects job PATCH requests to use /jobs/{jobId}.
  • Adds regression tests for both fixes.
File summaries
File Description
base_job.py Refreshes attachment container SAS URIs.
_operations.py Corrects the job update route.
test_job_attachments.py Tests attachment URI handling.
test_workspace.py Tests the PATCH resource path.
Review details

Suppressed comments (2)

azure-quantum/azure/quantum/job/base_job.py:381

  • This selects the default job-{id} container rather than the container encoded in self._details.container_uri. Jobs created with a custom container_name will therefore download from the wrong location. Request the fresh SAS using self.container_name and update the test expectation accordingly.
            container_uri = self.workspace.get_container_uri(job_id=self.id)

azure-quantum/azure/quantum/job/base_job.py:400

  • Listing now ignores the job's actual linked container name and always targets job-{id}. This breaks list_attachments() for the supported custom-container flow in from_input_data; obtain the fresh SAS for self.container_name and cover that case in the attachment tests.
        container_uri = self.workspace.get_container_uri(job_id=self.id)
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@v-elegacheva v-elegacheva changed the title Fix upload/download/list attachment 401s and job update 404 Fix job attachment 401s for submitted jobs Sep 18, 2026
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI 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.

🟡 Changes recommended

Caller-supplied containers from different storage accounts can be redirected to same-named workspace containers.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

azure-quantum/azure/quantum/job/base_job.py:387

  • For jobs created with from_storage_uri(..., container_uri=...) against another storage account, this re-signs only the extracted container name in the workspace's configured account. The download then reads a different container rather than the job's explicitly linked one. Preserve a usable explicit job-level URI, or restrict workspace SAS refresh to URIs known to be in workspace storage.
            container_uri = self.workspace.get_container_uri(
                job_id=self.id,
                container_name=self.container_name,
            )

azure-quantum/azure/quantum/job/base_job.py:409

  • This loses the storage-account identity from a caller-supplied job container_uri: get_container_uri selects the workspace-linked/configured account using only the name. Consequently, list_attachments() can list an unrelated same-named container (or create and list an empty one) instead of the explicit container retained by from_storage_uri. Preserve a usable explicit URI or verify the account before refreshing its SAS through the workspace.
        container_uri = self.workspace.get_container_uri(
            job_id=self.id,
            container_name=self.container_name,
        )
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread azure-quantum/azure/quantum/job/base_job.py Outdated
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Connection-string workspaces still generate SAS tokens without list permission, leaving list_attachments broken.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread azure-quantum/azure/quantum/job/base_job.py
@v-elegacheva

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The attachment operations now handle unsigned and unusable SAS URIs with focused regression coverage.

Review effort: Balanced
Findings: 1 High severity

Open (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants