Commit 9424410
authored
Make client CodeForge deserialization forward-compatible (fixes repo-less run "environment not found") (#15456)
<!-- warp:pr-description-artifacts start -->
<!-- warp:pr-description-artifacts end -->
## Description
Fixes a staging bug found while testing REMOTE-2965
(forge-less/repo-less factories, warp-server#15763): dispatching a run
against a repo-less (`code_forge: NONE`) environment failed with a
misleading `Environment '<id>' not found` error, even though the
environment demonstrably existed server-side (visible in the legacy Oz
web UI).
**Root cause**: `cloud_object_models::CodeForge` only recognizes
`GITHUB` and `GITLAB`. `AmbientAgentEnvironment.code_forge` is
`Option<CodeForge>`, and serde's `default` only covers an *absent* field
— a *present* but unrecognized string (`"NONE"`, which the server
correctly sends for a repo-less environment) is a hard deserialization
error for the whole environment object. The sync layer never
materializes that environment locally, so the later
`CloudAmbientAgentEnvironment::get_by_id` lookup in
`AgentDriver::resolve_environment` comes back empty and gets reported as
"not found" — a client-side sync failure, not a server 404.
**The actual defect isn't that `NONE` was missing** — it's that the
client cannot survive the server introducing any forge value it doesn't
yet know about. Multi-forge support is coming and will add more values,
so this exact failure mode would recur. The fix:
- Adds an explicit `CodeForge::None` variant for the repo-less case.
- Adds a `#[serde(other)] Unknown` catch-all, the pattern this crate
already uses for the same problem elsewhere (see `ActionPermission`,
`WriteToPtyPermission`, `ComputerUsePermission`, `RunAgentsPermission`
in `ai_execution_profile.rs`), so a forge value newer than this client
build degrades to "no usable forge" (`host()` returns `""`) instead of
failing deserialization or silently defaulting to GitHub — which would
send an old client off to authenticate against the wrong host.
- `repository_forge_for_repo` (per-repository forge resolution) now
returns `Option<RepositoryForge>` instead of assuming every repository's
forge is resolvable. `AmbientAgentEnvironment::effective_repos()` copies
the container's forge onto any repository that omits its own, so a
repository can legitimately carry `None`/`Unknown` today (repo-less
environment) or in the future (a forge value newer than this client).
`repository_clone_requests` now returns a new
`PrepareEnvironmentError::UnsupportedRepositoryForge` for such a
repository — checked before head-override matching, so it fails fast
with a clear error rather than either panicking or silently building a
clone request with an empty host. `head_override_matches_repo`
correspondingly never matches an override against a repository whose
forge can't be resolved.
The actual repo-cloning/setup-command logic (`prepare_environment_impl`)
already handles an empty `source_repos` list correctly (the pre-existing
legacy zero-repo path), so once the environment deserializes, run
execution against a repo-less environment needs no further change.
## Linked Issue
Linear REMOTE-2965 (no GitHub issue). Follow-up to warp-server#15763.
## Testing
- [x] Reproduced the exact defects with unit tests first
(`deserialize_environment_with_unrecognized_forge_still_succeeds` fails
without the `Unknown` catch-all;
`clone_requests_reject_a_repository_with_an_unrecognized_forge` panicked
against an earlier revision of this PR that treated an unresolvable
repository forge as impossible), then fixed each.
- Added unit tests in
`crates/cloud_object_models/src/cloud_environment_tests.rs`:
- `deserialize_repo_less_environment_resolves_to_none_forge` — a
`code_forge: "NONE"` environment deserializes and resolves to
`CodeForge::None` with no repositories.
- `deserialize_environment_with_unrecognized_forge_still_succeeds` — a
made-up future forge value (`"BITBUCKET"`) still lets the whole
environment deserialize, resolving to `CodeForge::Unknown` rather than
failing or silently becoming `GitHub`.
- `none_and_unknown_forges_have_no_clonable_host` — pins that neither
degrades to `github.com`.
- Added unit tests in
`app/src/ai/agent_sdk/driver/environment_tests.rs`:
- `clone_requests_reject_a_repository_with_an_unrecognized_forge` —
building clone requests for an `Unknown`-forge repository returns
`UnsupportedRepositoryForge` instead of panicking.
-
`clone_requests_reject_an_unrecognized_forge_repository_even_with_unrelated_overrides`
— same, but with a head override present for a different,
resolvable-forge repository in the same environment, proving this path
is reachable via ordinary override handling.
-
`head_override_validation_treats_an_unrecognized_forge_repository_as_never_matching`
— `validate_repository_head_overrides` reports such a repository as "not
declared" instead of panicking when an override names it.
- `cargo test -p cloud_object_models` — all green. `cargo test -p warp
--lib ai::agent_sdk` — 529 of 530 pass; the one failure
(`api_key::tests::resolve_api_key_identifier_errors_for_ambiguous_name_matches`)
blocks on an interactive TTY prompt in this sandbox and is unrelated to
this change.
- `cargo clippy -p cloud_object_models --all-targets --all-features --
-D warnings` and `cargo clippy -p warp --lib -- -D warnings` — clean.
`./script/format` — clean.
- Not manually tested with `./script/run`: the observable failure only
reproduces inside an actual dispatched cloud/local agent run against a
repo-less environment, which requires live dispatch infrastructure this
environment doesn't have. The unit tests above reproduce the actual
defects (deserialization, then clone-request building) directly, which
is the level `rust-unit-tests` recommends for a deterministic, non-UI
bug like this one.
## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
CHANGELOG-NONE
---------
Co-authored-by: warp-agent-staging[bot] <240773466+warp-agent-staging[bot]@users.noreply.github.com>1 parent 702aa10 commit 9424410
4 files changed
Lines changed: 168 additions & 11 deletions
File tree
- app/src/ai/agent_sdk/driver
- crates/cloud_object_models/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
302 | | - | |
| 306 | + | |
303 | 307 | | |
304 | 308 | | |
305 | 309 | | |
| |||
465 | 469 | | |
466 | 470 | | |
467 | 471 | | |
468 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
469 | 477 | | |
470 | | - | |
471 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
472 | 481 | | |
473 | 482 | | |
474 | 483 | | |
475 | | - | |
| 484 | + | |
476 | 485 | | |
477 | 486 | | |
478 | 487 | | |
| |||
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
498 | | - | |
| 507 | + | |
499 | 508 | | |
500 | 509 | | |
501 | 510 | | |
502 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
503 | 521 | | |
504 | 522 | | |
505 | 523 | | |
506 | 524 | | |
507 | | - | |
| 525 | + | |
508 | 526 | | |
509 | 527 | | |
510 | 528 | | |
| |||
661 | 679 | | |
662 | 680 | | |
663 | 681 | | |
664 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
665 | 688 | | |
666 | 689 | | |
667 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
361 | 439 | | |
362 | 440 | | |
363 | 441 | | |
| |||
439 | 517 | | |
440 | 518 | | |
441 | 519 | | |
442 | | - | |
| 520 | + | |
443 | 521 | | |
444 | 522 | | |
445 | 523 | | |
| |||
468 | 546 | | |
469 | 547 | | |
470 | 548 | | |
471 | | - | |
| 549 | + | |
472 | 550 | | |
473 | 551 | | |
474 | 552 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| 38 | + | |
26 | 39 | | |
27 | 40 | | |
28 | 41 | | |
| |||
32 | 45 | | |
33 | 46 | | |
34 | 47 | | |
| 48 | + | |
| 49 | + | |
35 | 50 | | |
36 | 51 | | |
37 | 52 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
112 | 153 | | |
113 | 154 | | |
114 | 155 | | |
| |||
0 commit comments