fix(workspace): branch-aware --ui job, roll back sandbox config on failed create (#755) - #756
Draft
padak wants to merge 1 commit into
Draft
fix(workspace): branch-aware --ui job, roll back sandbox config on failed create (#755)#756padak wants to merge 1 commit into
padak wants to merge 1 commit into
Conversation
…iled create (#755) `workspace create --ui` failed in every combination and left an orphaned keboola.sandboxes config behind each time. Two distinct causes: 1. The Queue job was created without branchId, so on an alias pinned to a dev branch the Queue resolved the config on the default branch and answered 400 "Cannot resolve job parameters: Configuration ... not found". The config existed -- in the dev branch. The job is now queued on the branch the config was created in, and the follow-up workspace lookup uses that same resolved branch instead of the job's branchId echo (which is null on the default branch and crashed int()). 2. On the default branch the job succeeds and nothing is attached: the keboola.sandboxes component dropped Snowflake/BigQuery workspace provisioning in 2026-03 (keboola/sandboxes 53e1b7e9, "remove SQL workspace support"). Its `create` task now only registers a sandbox-service record and writes parameters.id into the config; the Keboola UI creates SQL workspaces through SQL Editor sessions instead. kbagent cannot fix that server-side, so the WORKSPACE_NOT_FOUND error now names the job and says why, and tells the caller not to retry. Rollback: whenever step 2 (Storage workspace or Queue job) fails, the sandbox config from step 1 is moved to the trash -- headless and --ui alike -- and the ORIGINAL error is annotated (message + details: sandbox_config_id, sandbox_config_rolled_back, branch_id, job_id). A failed cleanup is surfaced with the exact `config delete` to run and never masks the triggering failure. The command layer forwards details into the --json error envelope. Verified live on project 6016 (Snowflake, storage-branches) A/B against the installed 0.93.1: main branch -> same green job, config now in the trash instead of live; dev branch -> the 400 is gone (job runs on the dev branch), honest error, config trashed; headless create still works on both branches. Docs: gotchas.md, workspace-workflow.md Option C, commands-reference.md, context.py, CLAUDE.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
kbagent workspace create --uifailed in every combination reported in #755 and left an orphanedkeboola.sandboxesconfig behind each attempt. This PR fixes what kbagent can fix and makes the rest honest.1. Dev branch: Queue 400
Cannot resolve job parameters: Configuration ... not foundThe sandbox config was created in the pinned dev branch (step 1), but the Queue job was created without
branchId, so the Queue looked for the config on the default branch. The job is now queued on the resolved branch, and the follow-uplist_config_workspacesuses that same branch instead ofint(job["branchId"])(which isnullon the default branch -- a latentTypeErroron the same line).2. Main branch: green job,
WORKSPACE_NOT_FOUNDRoot cause is server-side and not fixable here: the
keboola.sandboxescomponent removed Snowflake/BigQuery workspace provisioning on 2026-03-26 (keboola/sandboxes@53e1b7e9, "refactor: remove SQL workspace support" --WorkspaceManager.phpdeleted). Itscreatetask now only registers a sandbox-service record (POST /sandboxes) and writesparameters.idback into the config; no Storage workspace is created and the job still reportssuccess. The Keboola UI creates SQL workspaces through SQL Editor sessions (editorservice,POST /sql/sessions) --apps/kbc-ui/.../sandboxes/Actions.tsxroutessupportSessions(type)(snowflake/bigquery) tocreateSession, never to the job. TheWORKSPACE_NOT_FOUNDmessage now names the job, explains why nothing is attached, and says not to retry (it is not a provisioning race).The job is deliberately still queued rather than refused up front: a BYOC/private stack running an older
keboola.sandboxesimage may still provision SQL workspaces through it.3. Rollback (both modes)
Whenever step 2 (Storage workspace / Queue job) fails, the sandbox config from step 1 is moved to the trash (
config restore-able), for headless and--uialike. The original error is annotated -- message +details:sandbox_config_id,sandbox_config_rolled_back,branch_id, andjob_idfor--ui. A failed cleanup is reported (sandbox_config_rolled_back: false,sandbox_config_cleanup_error) with the exactconfig deleteto run; it never masks the triggering failure. The command layer forwardsdetailsinto the--jsonerror envelope.Docs (silent-drift surfaces)
gotchas.md(new entry,since vNEXT),workspace-workflow.mdOption C,commands-reference.md,context.pyAGENT_CONTEXT,CLAUDE.mdcommand list,--uioption help.How it was tested
tests/test_workspace_service.py::TestCreateWorkspaceUiMode,tests/test_workspace_cli.py): branchId forwarded on dev and default branch, nullbranchIdecho tolerated, rollback on no-workspace / on Queue rejection / on headless failure, cleanup failure surfaced not swallowed,--jsondetails envelope.make checkgreen (6576 passed).storage-brancheson) against the installed 0.93.1:parameters.id= sandbox-service id, no Storage workspace); branch build -> same green job, config in the trash,details.sandbox_config_rolled_back: true.WORKSPACE_NOT_FOUND, config trashed.Not in this PR (product decision)
Restoring a working
--uimeans driving the SQL Editor session API (POST /sql/sessions-> pollstatus: ready->workspaceId//credentials): a new HTTP client for theeditorservice plus session-aware list/delete. Alternatively deprecate--ui. Either way it is a separate decision; suggested fix 4 in the issue (workspace gcdetecting config-without-workspace) is also left out since this PR stops that debris from being created in the first place.Fixes #755