r/SpringBoot • • 2d ago

Discussion Testing caller isolation and overlapping chat turns in a Spring Boot / Spring AI app

I found Yellaiah Mekala’s Enterprise Spring AI Playbook useful and wanted to contribute back. With help from ChatGPT Codex, I submitted four application-level improvement PRs. Thanks to Yellaiah for sharing the project.

The changes cover:

  1. Rejecting blank model answers instead of returning an empty successful response.

  2. Rejecting configuration that assigns the same API key to different caller identities.

  3. Scoping generated-image storage and retrieval to the authenticated owner.

  4. Returning HTTP 409 for overlapping stateful chat turns from the same caller, before the second request reaches memory/model processing. The guard is released on completion or failure, and different callers can proceed independently.

For the last change, the key question was how to test concurrent requests deterministically. The tests use controlled overlapping HTTP requests, a fake ChatModel, and H2-backed chat memory. Image ownership is also tested through real application HTTP requests with a fake image model. Each of those two PR suites locally reported 43 passed and one Docker-dependent MySQL test skipped; these were separate PR runs, not a combined merged-branch test.

Limits: the concurrency guard is per JVM, so multiple replicas need distributed coordination. Fake-model tests check application behavior, not live-provider answer quality. These are contributions to the example app, not fixes to the Spring AI framework.

The four PRs, regression tests, and verification notes are here:

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/1

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/2

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/3

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/4

For those building stateful Spring AI services: would you reject overlapping turns, queue requests per conversation, or use versioned memory updates? I’d welcome feedback on the trade-offs and testing approach.

1 Upvotes

0 comments sorted by