Skip to content

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

Open
Sankalp-Mittal wants to merge 7 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 7 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

Switch the DABs state filer read (bundle/deploy/filer.go, stateFiler.Read) from
GET /api/2.0/workspace-files/{path} to the SDK's Workspace.Download(ctx, absPath), which issues
GET /api/2.0/workspace/export?path=<path>&direct_download=true. This reads the bundle state files
(terraform.tfstate, resources.json) from the workspace.

Why

The workspace-files endpoint is deprecated and 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.

Implementation

Reads go through the SDK's Workspace.Download helper, so there is no separate API client, no manual
auth.WorkspaceIDHeaders routing headers (the SDK sets these), and no intermediate buffer —
Download returns the streaming body directly.

direct_download=true is load-bearing: plain /workspace/export returns base64 JSON capped at 10 MB,
while the streaming variant handles files up to 500 MB, so large state files stream through fine.

Testing

  • Regenerated acceptance goldens: request traces now show GET /api/2.0/workspace/export with
    direct_download=true (user_agent, state suites).
  • Validated against a real workspace (dogfood): streaming export returns the state bytes correctly
    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: 4612ac8

Run: 32278836861

Env 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 1 4 274 1162 9:36
🔄​ aws windows 2 1 4 274 1160 11:37
💚​ azure linux 1 4 273 1162 11:01
💚​ azure windows 1 4 275 1160 6:57
💚​ gcp linux 1 4 274 1162 10:21
🔄​ gcp windows 1 1 4 275 1160 8:30
8 interesting tests: 4 SKIP, 3 flaky, 1 RECOVERED
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
🔄​ TestSyncIncrementalFileSync ✅​p ✅​p ✅​p ✅​p ✅​p 🔄​f
🔄​ TestFilerWorkspaceNotebook ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p
🔄​ TestFilerWorkspaceNotebook/pythonJupyterNb.ipynb ✅​p 🔄​f ✅​p ✅​p ✅​p ✅​p
Top 12 slowest tests (at least 2 minutes):
duration env testname
3:46 gcp windows TestFilerWorkspaceFilesExtensionsDelete
3:21 azure windows TestAccept
3:00 aws windows TestAccept
2:54 gcp linux TestFilerWorkspaceFilesExtensionsStat
2:52 gcp windows TestAccept
2:29 gcp linux TestFilerWorkspaceFilesExtensionsReadDir
2:24 gcp linux TestImportDirWithOverwriteFlag
2:21 azure linux TestFilerWorkspaceFilesExtensionsReadDir
2:09 azure linux TestFilerRecursiveDelete/workspace_files
2:08 azure windows TestFilerWorkspaceFilesExtensionsStat
2:04 gcp windows TestImportDirDoesNotOverwrite
2:00 azure windows TestImportDir

@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
@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 Outdated
// 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

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.

Also modified the comment

@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.

@Sankalp-Mittal
Sankalp-Mittal force-pushed the sankalp-mittal/workspace-export-migration branch 2 times, most recently from 301ea4b to 284f5af Compare August 18, 2026 13:52
…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 e4d4b68 to d110a58 Compare August 18, 2026 14:55

@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.

Did you confirmed that this works for files bigger than 10MB? PR looks good to me other than why the API requests are vanishing in those tests.

Comment thread acceptance/bundle/state/basic/out.state.txt
@Sankalp-Mittal

Copy link
Copy Markdown
Collaborator Author

Did you confirmed that this works for files bigger than 10MB? PR looks good to me other than why the API requests are vanishing in those tests.

Yes I did, also fixed the API requests vanishing issue

"path": "/Workspace/Users/[USERNAME]/.bundle/state/default/state/deploy.lock"
}
}
{

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.

We get these extra reads in the output because reading of locks and state files already used this endpoint, but then the grep was made on the old api, when we shift the grep to the new endpoint these extra reads also creep up

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.

Since the reading of the locks is not what we are testing I am excluding this from the output grep

@shreyas-goenka
shreyas-goenka self-requested a review August 19, 2026 23:36

@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.

Awesome, thanks!

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