Skip to content

Migrate bundle state filer read off workspace-files to /workspace/export - #6219

Open
Sankalp-Mittal wants to merge 3 commits into
mainfrom
sankalp-mittal/workspace-export-migration
Open

Migrate bundle state filer read off workspace-files to /workspace/export#6219
Sankalp-Mittal wants to merge 3 commits into
mainfrom
sankalp-mittal/workspace-export-migration

Conversation

@Sankalp-Mittal

@Sankalp-Mittal Sankalp-Mittal commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

bundle: read deploy state via /workspace/export instead of deprecated workspace-files API

Summary

The DABs state filer (bundle/deploy/filer.go, stateFiler.Read) reads bundle state files
(terraform.tfstate, resources.json) from the workspace. It did this with a raw
GET /api/2.0/workspace-files/{path}. This PR switches that read to the officially supported
GET /api/2.0/workspace/export?path=<path>&direct_download=true.

Why

  • The old endpoint is deprecated and, more importantly, is mapped to no API scope. Under
    context-based ingress (CBI) with fine-grained scoped tokens, it was only reachable via the
    all_apis master scope, so bundle deploy returned 403s for customers on least-privilege scoped
    tokens. /workspace/export is properly scoped, so state reads now work under
    least-privilege auth.
  • The old call was a hand-rolled workaround in the first place; this replaces it with the supported API.

Key detail: direct_download=true

Plain /workspace/export returns base64 JSON capped at 10 MB — too small for large state files,
which is exactly why the workaround existed. direct_download=true selects the streaming variant
(500 MB for regular files), so large state files stream through fine. This flag is load-bearing:
without it the migration would regress large-state deploys.

Testing

  • Regenerated acceptance goldens: request traces now show GET /api/2.0/workspace/export with
    direct_download=true in place of the workspace-files reads (user_agent, state suites).
  • Real-workspace validation against dogfood (confirming streaming export returns the state bytes
    correctly) is in progress — not yet confirmed end-to-end.

This pull request and its description were written by Isaac.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: b11f1be

Run: 31603223249

Env 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 286 1135 7:58
💚​ aws windows 4 4 288 1133 6:02
💚​ azure linux 4 4 285 1135 7:38
💚​ azure windows 4 4 287 1133 6:36
💚​ gcp linux 1 5 286 1135 7:15
💚​ gcp windows 1 5 288 1133 6:37
8 interesting tests: 4 RECOVERED, 4 SKIP
Test Name aws linux aws windows azure linux azure windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R
Top 4 slowest tests (at least 2 minutes):
duration env testname
5:22 azure windows TestAccept
4:54 aws windows TestAccept
4:52 gcp windows TestAccept
2:18 gcp windows TestFilerWorkspaceFilesExtensionsStat

@Sankalp-Mittal Sankalp-Mittal changed the title Migrate bundle state filer read off workspace-files to /workspace/export (DECO-28007) Migrate bundle state filer read off workspace-files to /workspace/export Aug 12, 2026
@Sankalp-Mittal
Sankalp-Mittal force-pushed the sankalp-mittal/workspace-import-migration branch from 2a99228 to af88c8f Compare August 12, 2026 13:25
…tion

filer.go now reads state via /api/2.0/workspace/export (a2946f2b7); regenerate
the acceptance goldens to match. Note: state/basic and force_pull_commands
filter captured requests on the old workspace-files path, so their goldens are
now empty and their state-read assertions need the filters repointed at
/workspace/export (follow-up).

Co-authored-by: Isaac
@Sankalp-Mittal
Sankalp-Mittal force-pushed the sankalp-mittal/workspace-export-migration branch from 291eb0a to b11f1be Compare August 12, 2026 13:46
@Sankalp-Mittal
Sankalp-Mittal changed the base branch from sankalp-mittal/workspace-import-migration to main August 12, 2026 13:46
@Sankalp-Mittal
Sankalp-Mittal marked this pull request as ready for review August 12, 2026 13:52
Comment thread bundle/deploy/filer.go
// Read via the raw apiClient.Do (not the SDK's Workspace.Download) so
// auth.WorkspaceIDHeaders can drop the CLI-only "none" workspace-id sentinel
// that Download would send literally. See PR #6149 for the write-path equivalent.
urlPath := "/api/2.0/workspace/export?path=" + url.QueryEscape(absPath) + "&direct_download=true"

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.

Why can't we use the SDK again here? I don't follow the point about auth.WorkspaceIDHeaders. Can we make this comment clearer?

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.

Is it because the streaming endpoint is not accessible via the SDK?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no the issue is only when the during auth login the --skip-workspace flag is passed, this causes WorkspaceID = "none" to be passed (which I could handle separately, but I wanted to keep the code change as small as possible)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Can check out libs/auth/arguments.go:8 for definition of this sentinel

@shreyas-goenka shreyas-goenka 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, did not mean to approve the PR. The current PR is good but please lets clarify why SDK is not usable here.

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