-
[OPIK-5872] [BE] Fix demo data race conditions on signup (#6227)
发布于
2026-04-14 11:49:22 +00:00 - [OPIK-5872] [BE] fix: add polling for API key and project readiness in demo data creation
After the demo data simplification (
d3b3c4f5aa), demo data creation became
fast enough to outrun backend state propagation, causing two race conditions:- 401: API key not yet propagated when demo data creation starts
- 404: project not yet queryable when thread close/feedback operations run
Changes:
- Add api_key_ready() poll with exponential backoff before starting
- Add project_exists() poll with exponential backoff after flush
- Deduplicate thread IDs (set comprehension instead of list)
- Include workspace_name in error logs for traceability
- Strip verbose HTTP headers from error messages (only log status + body)
- Check and log flush() result to surface SDK auth failures
- [OPIK-5872] Address review feedback
- Return early if flush() fails instead of continuing to poll
- Check project_exists() first to avoid API key poll cost for existing projects
- Use %s-style logger formatting consistently (lazy evaluation)
- Add GET /v1/private/projects mock to test for api_key_ready() call
下载附件