diff --git a/coding-agent/src/coding_agent/ui/http_server.py b/coding-agent/src/coding_agent/ui/http_server.py index 68dfed855..3d25d0b0b 100644 --- a/coding-agent/src/coding_agent/ui/http_server.py +++ b/coding-agent/src/coding_agent/ui/http_server.py @@ -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, @@ -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)): diff --git a/coding-agent/src/coding_agent/ui/schemas.py b/coding-agent/src/coding_agent/ui/schemas.py index 280dcb891..78bcc0571 100644 --- a/coding-agent/src/coding_agent/ui/schemas.py +++ b/coding-agent/src/coding_agent/ui/schemas.py @@ -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): diff --git a/coding-agent/tests/ui/test_http_server.py b/coding-agent/tests/ui/test_http_server.py index b8d8c7ef7..374bdd9bf 100644 --- a/coding-agent/tests/ui/test_http_server.py +++ b/coding-agent/tests/ui/test_http_server.py @@ -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 ):