feat(proxy): Add support for secret update using SSE#169
feat(proxy): Add support for secret update using SSE#169
Conversation
Greptile SummaryThis PR adds demand-driven SSE (Server-Sent Events) support to the Infisical proxy, allowing real-time cache invalidation when secrets are created, updated, or deleted. When Key changes:
Issues found:
Confidence Score: 3/5Safe to merge with caveats — the authorization fix is solid, but the missing initial authentication creates a guaranteed-failure first connection per project and a small event-loss window that should be addressed before production use. The core authorization concern from the previous review cycle has been properly resolved. However, a P1 logic issue remains: SSEAuthState starts with an empty token, making every project's first SSE connection guaranteed to receive a 401. While the retry loop recovers, it introduces a window where early mutation events can be silently dropped, leaving the cache stale. The 64 KB scanner line-limit is also a real reliability gap for large batch events. Together these two issues are material enough to warrant fixes before merge. packages/proxy/sse.go — initial token not set in SSEAuthState and default scanner line-size limit both need attention. Important Files Changed
Reviews (2): Last reviewed commit: "change to use httpclient" | Re-trigger Greptile |
|
@greptile check the comments added and the changes. See if the problems still make sense. Update the summary |
|
The E2E test will only work when the other PR gets merged, since this depends on a change there. |
810bd46 to
4f6ea97
Compare
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, push a new commit or reopen this pull request to trigger a review.
5afe349 to
5c181a2
Compare
a3ae7cc to
807aa40
Compare
packages/cmd/proxy.go
Outdated
| proxyStartCmd.Flags().Bool("use-sse", false, "Enable SSE (Server-Sent Events) mode for real-time cache invalidation. When enabled, the static secrets refresh loop is disabled and --client-id/--client-secret are required.") | ||
| proxyStartCmd.Flags().String("client-id", "", "Universal auth client ID for SSE (env: INFISICAL_UNIVERSAL_AUTH_CLIENT_ID)") | ||
| proxyStartCmd.Flags().String("client-secret", "", "Machine identity client secret for universal auth (env: INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET)") | ||
| proxyStartCmd.Flags().Bool("event-subscription-enabled", false, "Enable Event Subscription mode for real-time cache invalidation. When enabled, the static secrets refresh loop is disabled. If event subscriptions are unavailable, the proxy will fall back to a polling mechanism. `--client id` and `--client-secret` are required when this is set to true ") |
There was a problem hiding this comment.
I would be in favor of just --enable-event-subscriptions, seems cleaner?
e2e/proxy/proxy_test.go
Outdated
|
|
||
| if config.UseSSE { | ||
| args = append(args, "--use-sse") | ||
| args = append(args, "--event-subscription-enabled") |
|
@codex can you please re-review this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 807aa406b9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| go m.attemptSSEReconnection(projectId, environmentSlug) | ||
| } | ||
|
|
||
| go startProjectPollingLoop(pollCtx, m.cache, m.domainURL, m.resyncHttpClient, projectId, environmentSlug, m.pollingFallbackInterval, retrySSE) |
There was a problem hiding this comment.
Poll every cached environment during SSE fallback
transitionToPolling starts fallback polling for only one environmentSlug per project, but SSE subscriptions are managed per-project and static refresh is disabled when SSE mode is on. If a project has cached secrets in multiple environments (for example dev and prod) and SSE remains unavailable, only the selected environment is refreshed while the others can stay stale indefinitely.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This makes sense, but it would change the way how the pooling work (even the one that already exist). With this change, it will track all the environments+projects that the user requests (like happens on the general pooling)
Description 📣
Allow support to update secrets using SSE (server sent events)
Type ✨
Tests 🛠️