Conversation
The API's websocket feed listens on the generic `db_notifications` channel,
fed by `notify_trigger()`. The earlier env_id work enriched
`notify_specific_trigger_name()` instead, which only feeds the per-table
channels used by backend services -- so websocket events reaching the
frontend carried no env_id, and per-env subscription/permission filtering
dropped every environment-scoped event (live updates were broken).
- New migration enriches the generic `notify_trigger()` with the changed
row's environment, resolved per table (deployments/tasks/resources via
cluster; secrets/permissions via their env_id column; envs via their own
id). Other tables carry a null env_id.
- Websocket subscription matching now treats a no-env subscription as a
wildcard ("every permitted event of this table"), so globally loaded
collections such as envs and env_user_permissions -- whose events now
carry an env_id -- still reach subscribers, gated by permissions.
Verified against PostgreSQL that db_notifications payloads carry the
correct env_id for every environment-scoped table, including DELETE.
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.
Critical fix — live websocket updates are broken on
mainThere are two parallel notification trigger systems:
notify_trigger()is attached to every table and notifies thedb_notificationschannel. This is the channel the API's websocket feed listens on (main.rs→NotificationListeningOpts::all()).notify_specific_trigger_name()notifiesdb_<table>_notifications, consumed by the backend services (k8s-agent, status-updates, resource-sync, chart-discovery).The earlier env_id enrichment landed on the per-table function, not the generic one the API reads. As a result, websocket events reaching the frontend carry no
env_id, and with the per-env subscription + permission filtering, every environment-scoped event is dropped — live updates don't reach the UI.What this does
New migration enriches the generic
notify_trigger()with the changed row's environment, resolved per table:deployments/deployment_tasks→k8s_clusters.env_id(viacluster_id)deployment_resources→deployments→k8s_clusters.env_idsecrets/env_user_permissions/deployment_permissions→ theirenv_idcolumnenvs→ its ownidBecause the trigger uses
OLDonDELETE, the env is resolved even for deletions.Wildcard subscription matching: a subscription with no env is now a wildcard ("every permitted event of this table"). Globally loaded collections (
envs,env_user_permissions) — whose events now carry anenv_id— keep reaching subscribers, still gated by the permission scope. Env-scoped subscriptions remain exact-match.Testing
Verified against a live PostgreSQL that
db_notificationspayloads carry the correctenv_idfor every environment-scoped table (deployments, tasks, resources, secrets, permissions, envs) including onDELETE, andnullfor global tables.cargo build+cargo fmtclean.This is a prerequisite for the live per-env deployment counts work, which builds on env-tagged events.
https://claude.ai/code/session_019WuF56UqDxdJkYmk4zXD88
Generated by Claude Code