Repository navigation
Fix App Studio first-turn integration conflicts - #1077
Conversation
|
@mjudeikis-bot review |
mjudeikis
left a comment
There was a problem hiding this comment.
One Note, no Critical or Warning findings.
What the PR does vs. the code: replaces the whole-Project Update with a JSON Patch (test uid, test generation, add /spec/environments), reloads and re-merges on a stale guard, and maps exhausted confirmed conflicts to 409. The code matches that description.
Checked
- Read beyond the diff:
materializeAutomaticProjectIntegrationsand its caller flow (projectIdentityTokenrefresh),writeAssistantThreadError(assistant_threads.go),writeProjectError(projects.go),writeError(http.go: Conflict->409, Invalid->400),TypedResource.Patchinproviders/app-studio/client. - Correctness: retry loop terminates (bounded by
automaticIntegrationUpdateAttempts); the last-attempt, UID-change and deletion-timestamp exits all break with the right error; the retry now materializes the filteredmaterializableset (the old code used unfilteredtargetson retry). No defect found. - Concurrency: status-only updates do not bump generation, so the guard does not trip on status reconciliation. A spec edit trips the guard and the reload merges onto the latest object. No defect found.
- Tenancy/kcp: the client is the caller-scoped per-request client; no fixed workspace, no new credential. Not applicable beyond that.
- Provider contract, API/codegen, portal, security: not applicable (no manifest, chart, API type, route or portal change; no credential reaches an error string).
- Tests: new tests cover concurrent status, concurrent revocation, replacement Project (UID), retry exhaustion -> 409, and validation error preserved without reload. The classification of the stale-guard 422 is only tested with a synthetic error built to match the heuristic (see the Note).
- Commands:
cd providers/app-studio && go build ./...OK;go vet ./api/OK;go test -count=1 ./api/OK. Rootmake lintand the e2e suites were not run: the change is confined to the standalone provider module and its unit tests, and the e2e needs a Tilt/kcp stack.
| return nil, fmt.Errorf("persist automatic provider integrations: %w", lastErr) | ||
| } | ||
|
|
||
| func isAutomaticIntegrationPatchRejection(err error) bool { |
There was a problem hiding this comment.
Note: Stale-guard detection depends on kcp returning a detail-less 422
isAutomaticIntegrationPatchRejection treats any 422 with empty Details as a failed test op. The unit tests feed it a synthetic NewGenericServerResponse(422) built to match, so only the manual dry run backs the real kcp shape. A different 422 with no details (for example from an admission webhook) is also reloaded once. It is bounded and returns the original error when the generation is unchanged, so this is contained. When the generation is unchanged, the caller gets that raw 422 mapped to 400 by writeError. Consider noting the kcp assumption next to the function, or covering it in an e2e that races a spec edit against a first turn.
// kcp reports a failed JSON Patch `test` op as a detail-less 422; see e2e <name>.
Summary
Project creation can succeed while the first assistant request fails with a conflict. Automatic integration discovery previously saved the whole Project using its resource version, which can change while the controller reconciles status.
spec.environments, guarded by the Project UID and generation. Reload and merge after a concurrent spec edit so existing bindings and revocations survive.Verification