Skip to content

Commit

Permalink
Fix multiple object redefinitions in extensions (#108)
Browse files Browse the repository at this point in the history
* Fix error on empty observable_type_id_map

* Use previously modified object when multiple extensions extend the same object

* Update page_view.ex

The check in cond was correct. The fix is to set observable_type_id_map to nil if there is no `observable` object defined in the schema.

Signed-off-by: Rick Mouritzen <[email protected]>

---------

Signed-off-by: Rick Mouritzen <[email protected]>
Co-authored-by: Rick Mouritzen <[email protected]>
  • Loading branch information
PierreSedon and rmouritzen-splunk authored Sep 19, 2024
1 parent a7ee6e9 commit f0de5e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/schema/cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ defmodule Schema.Cache do

Logger.info("#{key} #{kind} is patching #{base_key}")

case Map.get(items, base_key) do
# First check the accumulator in case the same object is extended by multiple extensions,
# that way the previous modifications are taken into account
case Map.get(acc, base_key, Map.get(items, base_key)) do
nil ->
Logger.error("#{key} #{kind} attempted to patch invalid item: #{base_key}")
System.stop(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/schema_web/views/page_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ defmodule SchemaWeb.PageView do
if observable_object do
observable_object[:attributes][:type_id][:enum]
else
{nil, nil}
nil
end

cond do
Expand Down

0 comments on commit f0de5e9

Please sign in to comment.