Repository navigation
[AI-3712] Fix the api integration tests' compile on main - #2341
Merged
Merged
Conversation
kanat
commented
Nov 24, 2026
kanat
left a comment
Collaborator
Author
There was a problem hiding this comment.
VERDICT: GO
Round 1, head 41b6352 merged onto current main (6d3cb55, clean).
- The change restores what #2277 meant.
callOnnow shortenss.router.phoneWindowands.router.callLimit(the router fields #2293 added, set from the constants inserver.go:618-619) and its cleanup puts the saved values back, the same shape asscheduled_phone_test.go:136-138. - No other site assigns the old names:
git grep -E 'scheduledPhoneWindow|scheduledCallLimit' -- accelerationfinds only the constants, their uses inserver.go:618-619and comments. go vet ./... && go vet -tags integration ./...fromacceleration/compiles the whole module, no output.go test -tags integration ./internal/api -run TestTelnyxUnpaidSuite -count=1 -von a private DB: ok (105 s), 48 pass, 0 skip. The nine tests that reachcallOn(directly or throughringingOn) all ran and passed.- No mutation check: test-only change, and the tests above run it.
- CI: this is a draft, the integration jobs are skipping on the head. CI runs at
gh pr ready.
kanat
marked this pull request as ready for review
November 24, 2026 08:14
thesyncim
approved these changes
Nov 24, 2026
thesyncim
left a comment
Member
There was a problem hiding this comment.
Checked: merges cleanly onto current main and go vet -tags integration ./internal/api/ passes on the merge. Merging to unblock every PR's integration (api) while Kanat is out.
This was referenced Nov 24, 2026
Nash0x7E2
pushed a commit
that referenced
this pull request
Nov 24, 2026
…th the refusal, not a 500 (#2354) **Problem** #2295 refused a session on a deployment whose Stream app keys Stream rejects with its own sentence. A fork reached that refusal through `refusedRequest`, and so did an app-mode create whose own app rejects its keys. #2295 relied on `refusedRequest` answering any error as a 400 with the error's text. #2248, already on #2295's branch, had changed that: an error `refusedRequest` does not recognise is now a 500 "something went wrong". These paths never answered correctly on main. Their tests in `SelfHostedSessionsSuite` and `AppModeSessionsSuite` could not run until #2341 fixed the package's compile, so `integration (api)` fails on every PR. **Fix** - `refusedRequest` (money.go) answers `ErrNoStreamKeys` and `ErrStreamKeysRejected` through `unkeptAnswer`, as `not_configured`. Create, fork, resume, voice and the socket now give this refusal the same code and status. - In app mode, `unkeptIn` (session/stream_keys.go) maps Stream's 401 for an app's own keys to a new `ErrAppStreamKeysRejected`. That error is a caller mistake, answered as `invalid_request` in our own words. It names no deployment variable and none of Stream's text. Before, the raw `StreamError` went through as a 500. - Create and fork log Stream's answer as create did before (`logUnkept`). A resume answers correctly but does not log the cause. **Tests** - `TestAForkOnKeysStreamRefusesNamesTheKeysWithNothingOfStreams` caught a fork answered as a 500. It now also asserts `not_configured`. It failed on main with 500 "something went wrong". - `TestAPersistedTextSessionIntoAnAppRefusingItsKeysIsNotTheDeploymentsToFix` caught an app's refused keys answered as a 500. It failed on main with a 500. It now also asserts `invalid_request` and our sentence, and that Stream's "api_key not valid" stays out of the body. Without that last check, putting back the old catch-all `invalidRequest(err.Error())` would pass. - `TestInAppModeTheAppIsTheCustomers` (unit) now expects `ErrAppStreamKeysRejected` without `STREAM_API_KEY`, where it expected nil. - Both suites passed 3 times with `-count=3`. Five mutants were each killed: no unkept case in `refusedRequest`, the app-mode branch returning nil, the app refusal answered `not_configured`, the old catch-all, and the app refusal dropped from `callerMistakes`.
kanat
added a commit
that referenced
this pull request
Nov 25, 2026
## Why A Slack app configuration token rotates: `Server.configToken` calls `Rotate`, and Slack then treats the refresh token it just got as spent. The new pair was saved with one `Upsert`. When that one save failed (a dropped connection, a short database outage), the new pair was gone and the stored one was dead, so the customer had to send a new `config_refresh_token`. Same pattern as the credential refresh fixed in #2192, found in its sibling sweep (AI-3504). ## How it works ``` configToken ├─ Rotate (Slack spends the old refresh token) └─ saveConfigToken ├─ Upsert ok -> done ├─ failed, store.Unwritable? -> stop (a retry fails the same way) ├─ wait 100 ms, Upsert again ├─ wait 200 ms, Upsert again └─ still failing -> one error log (customer, connector, attempts; no token), error returned as before ``` - Bound: 3 saves, 300 ms of pauses, each save at most the store's 2 s (`credentialDetachedTimeout`), so under 6.3 s, inside the provider app lock the caller already holds. - The save is an upsert, so one whose answer was lost and landed is safe to repeat. - Reused: `store.Unwritable` (the rule behind the resolver's `retryable`). Not reused: the resolver's `saveAttempts`, `saveAgain` and `wait` are unexported and tied to its credential store, and the 10DLC service repeats the same numbers; a shared helper would need a package of its own, so the three constants stay local with the reason in the comment. - API answers are unchanged: a failed save is the same 500 as before. ## Changes - `connector_provider_apps.go`: `saveConfigToken` with its two constants; `configToken` logs the last failure. - Tests: `RouterSuite.failFirstQueries` (fail only the first n queries that name a value, on the suite's existing query-hook seam); four tests in `ConnectorProviderAppsSuite`: `TestARotatedConfigTokenWhoseFirstSaveFailsIsSavedByTheNextAndUsedWithoutAnotherRotation`, `TestARotatedConfigTokenWhoseEverySaveFailsIsLoggedOnceWithoutItsWordsAndAnsweredAsAnyFailure`, `TestARotatedConfigTokenThatPostgresRefusesIsNotSavedAgain`, `TestARotatedConfigTokenWhoseSaveLosesItsConnectionIsSavedByTheNextAndUsedWithoutAnotherRotation`. - Second commit, unrelated to AI-3550: `TelnyxUnpaidSuite.callOn` assigned the package-level `scheduledPhoneWindow` and `scheduledCallLimit`, which #2293 made constants, so the api package's integration tests did not compile on `main` (`go vet -tags integration ./internal/api` at dc88f2f). It sets them on the router as the other scheduled tests do. The same change is #2341 (AI-3712); whichever merges first, the other's copy merges clean. ## Validation | Defect | Test | Mutant that fails it | |---|---|---| | One failed save loses the pair | `TestARotatedConfigTokenWhoseFirstSaveFailsIsSavedByTheNextAndUsedWithoutAnotherRotation`: the next call uses the stored pair, no second rotation | no retry; `seam-always-fails` | | Retries without end, or without waiting | `...WhoseEverySaveFailsIsLoggedOnce...`: 3 attempts, at least 300 ms, 500 | unbounded; 2 attempts; no pause; constant pause | | A row Postgres refuses is saved again | `...ThatPostgresRefusesIsNotSavedAgain` (customer id past the index limit, SQLSTATE 54000): `attempts=1` | retry on `Unwritable` | | A token or its words in the log, no customer or connector in it | the all-fail test reads the one error line | token, refresh token, stored refresh in the line; no customer; no connector; warn level; no log | | The failure swallowed | all-fail test: status 500 | return nil | | A dropped connection (SQLSTATE 57P01) is not retried | `...WhoseSaveLosesItsConnectionIsSavedByTheNext...`: the next call uses the stored pair | retry only on context deadline; never retry a Postgres-reported error | | A refused row's log names the sent token | `...ThatPostgresRefusesIsNotSavedAgain`: the log line holds no sent token | log `sent` | | The every-save-fails log line has extra or missing fields | `...WhoseEverySaveFailsIsLoggedOnce...`: the line has exactly time, level, msg, customer, connector, attempts, error | sealed pair as an extra field | | The first-save test passes without a failed save | `...WhoseFirstSaveFailsIs...`: the seam fails exactly one save (two saves ran) | seam off by one | | The all-fail call waits on every save | `...WhoseEverySaveFailsIsLogged...`: the call ends under 2 s | 1 s sleep after every save | - Tests run against real Postgres and the suite's fake Slack; the failing save is the suite's per-suite query hook, no DDL and no store mock. - Run: `go test -tags integration ./internal/api -run TestConnectorProviderAppsSuite` passes, and the suites that use `failQueries` (authorizations, agent teams, channels, data move, knowledge urls, 10DLC, guests) pass on the tests that call it. The full integration run is CI's. - `go vet -tags integration ./internal/api`, `gofmt -l`, `go build ./...` are clean. - Not checked: Slack's real behavior on a spent refresh token (the fake takes the strict reading, as its comment says); whether `credentialDetachedTimeout` is the real worst case on a stalled network. The 3 x 100/200 ms bound is a choice, not measured, as in the resolver. ## Review rounds Round 1: main review NO-GO (no test of a dropped connection; two time and count gaps), security review GO with one log-field test gap. Round 2: all fixed in tests only; delta review GO, 24 mutants, none survived. Round 3: one comment word. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Why
The
apigroup of Integration (router) does not compile on main since dc88f2f (run 45350145644):#2277 set the package-level
scheduledPhoneWindowandscheduledCallLimitinTelnyxUnpaidSuite.callOn. #2293, merged before it, made them constants and moved the values a test changes onto the router. Each passed CI on its own. Until this lands, every PR whose CI runs theapigroup fails.Changes
callOnsetss.router.phoneWindowands.router.callLimitand restores them in its cleanup, asscheduled_phone_test.go:136-138does. Test-only.Validation
go vet -tags integration ./internal/api: compiles.go test -tags integration ./internal/api -run TestTelnyxUnpaidSuite -count=1: ok (99.7 s), including the three tests that go throughcallOn.🤖 Generated with Claude Code