fix(portal): adapt resource on resource_updated (#10247)

When filters are updated for a Resource, we need to first adapt the
resource before rendering it down to the Gateway. Otherwise, the gateway
may see a Resource that does not match its expected schema.
This commit is contained in:
Jamil
2025-08-23 13:53:20 -04:00
committed by GitHub
parent b774dee41d
commit 6d2ea0b224
2 changed files with 154 additions and 7 deletions

View File

@@ -666,9 +666,15 @@ defmodule API.Gateway.Channel do
# Send regardless of cache state - if the Gateway has no flows for this resource,
# it will simply ignore the message.
resource = Cache.Cacheable.to_cache(resource)
push(socket, "resource_updated", Views.Resource.render(resource))
{:noreply, socket}
case Resources.adapt_resource_for_version(resource, socket.assigns.gateway.last_seen_version) do
nil ->
{:noreply, socket}
adapted_resource ->
push(socket, "resource_updated", Views.Resource.render(adapted_resource))
{:noreply, socket}
end
end
defp handle_change(%Change{}, socket), do: {:noreply, socket}