Skip to content

Commit

Permalink
Fix error when endpoint missing
Browse files Browse the repository at this point in the history
We expect a hash to call "stringify_keys",
or raise if nil (when value is absent).
I18n returns "Translation missing" string if absent,
which isn't caught by "nil?" and errors with "stringify_keys".
  • Loading branch information
Samuelfaure committed Aug 6, 2024
1 parent 881ed0f commit 309d4e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/api_entreprise/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def custom_provider_errors
end

def load_dummy_definition!
missing_endpoints_definition = I18n.t("api_entreprise.missing_endpoints.#{path}")
missing_endpoints_definition = I18n.t("api_entreprise.missing_endpoints.#{path}", default: nil)

raise 'Endpoint(s) not found, check endpoints paths are available in OpenAPI file or in missing_endpoints.yml' if missing_endpoints_definition.nil?

@open_api_definition = missing_endpoints_definition.stringify_keys
Expand Down

0 comments on commit 309d4e9

Please sign in to comment.