Skip to content

fix: LoginSuccessCommitterTests.CommitAsync flakes with a JsonException on an empty auth_mode #449

Description

@karirafn

Symptom

The api CI job intermittently fails with three tests in Foundry.UnitTests.Modules.Credentials.Features.Login.LoginSuccessCommitterTests.CommitAsync failing together:

  • WhenAccountExists_PublishesCredentialsValidated
  • WhenAccountExists_SetsOAuthModeAndIdentity
  • WhenManualDispatchPauseExists_DoesNotClearManualPause

All three fail the same way:

System.Text.Json.JsonException : The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
   at Foundry.Modules.Credentials.Infrastructure.Configurations.ClaudeAccountConfiguration.DeserializeAuthMode(String json) in src/Modules/Credentials/Foundry.Modules.Credentials/Infrastructure/Configurations/ClaudeAccountConfiguration.cs:line 105
   at lambda_method(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()

The value converter is reading an empty string back out of the auth_mode column, so the row was either written with an empty value or read before the write landed.

Evidence

Observed on 2026-08-19 while merging the dependency PRs:

It reproduces on main with no dependency change involved, so it is not caused by the EF Core 10.0.11 bump (#436). It has not reproduced locally on Windows (2941/2941 passing).

Ruled out

  • Cross-test database sharing — the test class opens its own Data Source=:memory: SqliteConnection per instance and calls EnsureCreatedAsync in InitializeAsync, so each test class has a private database.

Worth investigating

  • Whether AuthModeJsonConverter.Write can produce an empty payload for some AuthMode variant (a converter that writes nothing leaves '' in the column rather than failing at write time).
  • Whether the static JsonSerializerOptions instances in ClaudeAccountConfiguration are being used from parallel test collections in a way that yields an empty write.

Because the failure is intermittent, a fix should come with a test that pins the round-trip for every AuthMode variant rather than relying on the CI job going green once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions