Commit d068854
fix: send deployment header from serverless presigned-URL IO manager (#25897)
## Summary
Materializing assets in a serverless org with **more than one full
deployment** fails with a 401 from the IO manager:
```
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:
https://<org>.agent.<env>.dagster.cloud/gen_io_storage_url?key=raw_orders&method=PUT
File ".../dagster_cloud/serverless/io_manager.py", line 138, in _get_presigned_url
resp.raise_for_status()
```
**Root cause.** `ServerlessPresignedURLIOManager._get_presigned_url`
builds its headers with the raw `get_dagster_cloud_api_headers(token,
DagsterCloudInstanceScope.DEPLOYMENT)` and **never passes a
`deployment_name`**, so the `Dagster-Cloud-Deployment` header is
omitted. Ursula's auth (`_get_deployment`) then falls back to "if the
org has exactly one deployment, use it; otherwise 401":
```
Organization has multiple deployments, but no deployment specified
```
Single-deployment serverless orgs hit the one-deployment branch and
worked; with per-deployment tenancy an org can now have `prod` +
`stage`, so it 401s.
Every other run-pod callback (compute logs, insights, defs-state,
GraphQL) goes through `instance.dagster_cloud_api_headers` →
`get_agent_headers`, which derives `deployment_name` from the instance
config. This IO manager was the only path that bypassed that helper.
## Fix
Thread `init_context.instance.deployment_name` into the manager and send
it in the header — matching how the non-presigned S3 path already reads
`instance.deployment_name`, and how every other caller sets the header.
## Test Plan
- `dagster_cloud_tests/serverless_tests/test_io_manager.py` → 13 passed.
Added an assertion that `dump_to_path` sends `Dagster-Cloud-Deployment`,
and that the factory threads `deployment_name` onto the manager.
- `just ty` → 0 errors.
## Changelog
Fix a 401 from the serverless IO manager when materializing assets in an
org with more than one full deployment.
Internal-RevId: 724b9db96b53cbc581e9460aa2038113b8b7176e1 parent 2f4af03 commit d068854
2 files changed
Lines changed: 12 additions & 3 deletions
File tree
- python_modules/dagster-cloud
- dagster_cloud_tests/serverless_tests
- dagster_cloud/serverless
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| 187 | + | |
185 | 188 | | |
186 | 189 | | |
187 | 190 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
101 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| 153 | + | |
148 | 154 | | |
149 | 155 | | |
150 | 156 | | |
| |||
331 | 337 | | |
332 | 338 | | |
333 | 339 | | |
334 | | - | |
| 340 | + | |
335 | 341 | | |
336 | 342 | | |
337 | 343 | | |
| |||
0 commit comments