Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions coding-agent/src/coding_agent/ui/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,11 @@ def _provisioned_execution_binding_from_request(
raise ValueError(
"cloud workspace provisioning requires cloud_workspace.enabled=true"
)
if body.workspace_source.kind == "git":
raise HTTPException(
status_code=501,
detail="git workspace source is not implemented yet",
)
_validate_workspace_source_phase_policy(
body.workspace_source.model_dump(mode="python"),
cloud_workspace_config,
Expand Down Expand Up @@ -1255,6 +1260,8 @@ async def create_session(
)
except Exception:
logger.exception("Failed to roll back provisioned cloud workspace")
if isinstance(exc, HTTPException):
raise exc
if isinstance(exc, RuntimeError):
raise HTTPException(status_code=500, detail=str(exc)) from exc
if isinstance(exc, (ValueError, TypeError)):
Expand Down
10 changes: 9 additions & 1 deletion coding-agent/src/coding_agent/ui/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ class DockerWorkspaceSourceRequest(BaseModel):
) = Field(None, min_length=1, max_length=20)


class GitWorkspaceSourceRequest(BaseModel):
kind: Literal["git"]
remote_url: str = Field(..., min_length=1, max_length=1000)
base_ref: str = Field(..., min_length=1, max_length=200)
base_sha: str = Field(..., min_length=1, max_length=100)
runtime_profile: str | None = Field(None, min_length=1, max_length=100)


ExecutionBindingRequest = LocalExecutionBindingRequest | CloudWorkspaceBindingRequest
WorkspaceSourceRequest = DockerWorkspaceSourceRequest
WorkspaceSourceRequest = DockerWorkspaceSourceRequest | GitWorkspaceSourceRequest


class PromptRequest(BaseModel):
Expand Down
38 changes: 38 additions & 0 deletions coding-agent/tests/ui/test_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,44 @@ async def test_create_session_rejects_workspace_provisioning_when_disabled(
"cloud workspace provisioning requires cloud_workspace.enabled=true"
)

async def test_create_session_rejects_git_workspace_source_until_supported(
self, client, monkeypatch, tmp_path
):
monkeypatch.setattr(
"coding_agent.ui.http_server._load_cloud_workspace_config",
lambda: {
"enabled": True,
"provider": "docker",
"workspace_root": str(tmp_path),
"container_name_prefix": "agent-",
**_test_runtime_profile_config(),
},
)
monkeypatch.setattr(
"coding_agent.ui.http_server.provision_cloud_binding_from_config",
lambda config, source: pytest.fail(
"git workspace source should fail before provider provisioning"
),
)

response = await client.post(
"/sessions",
json={
"workspace_source": {
"kind": "git",
"remote_url": "https://github.com/org/repo.git",
"base_ref": "main",
"base_sha": "abc123",
"runtime_profile": "universal",
}
},
)

assert response.status_code == 501
assert response.json()["detail"] == (
"git workspace source is not implemented yet"
)

async def test_create_session_rolls_back_provisioned_workspace_on_failure(
self, client, monkeypatch
):
Expand Down