OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
119 stars 32 forks source link

Credential schema validator throwing 500 on /credentials list #2018

Open sentry-io[bot] opened 3 months ago

sentry-io[bot] commented 3 months ago

USE THE 2018 BRANCH. The failing test has already been built.

My guess is that the customer here has a credential which, for one reason or another, no longer matches the schema required by that adaptor.

Right now, we should not be throwing a 500 on the credentials list view if one of the user's credentials doesn't match the JSON schema defined in the adaptor package.

Later, we need to handle:

CaseClauseError: no case clause matching: %ExJsonSchema.Validator.Error.Format{expected: "hostname"}

Sentry Issue: LIGHTNING-B0

CaseClauseError: no case clause matching: %ExJsonSchema.Validator.Error.Format{expected: "hostname"}
  File "lib/lightning/credentials/schema.ex", line 98, in Lightning.Credentials.Schema.error_to_changeset/2
  File "lib/enum.ex", line 2528, in Enum."-reduce/3-lists^foldl/2-0-"/3
  File "lib/lightning_web/live/credential_live/json_schema_body_component.ex", line 16, in LightningWeb.CredentialLive.JsonSchemaBodyComponent."fieldset (overridable 1)"/1
  File "lib/phoenix_live_view/tag_engine.ex", line 69, in Phoenix.LiveView.TagEngine.component/3
  File "lib/lightning_web/live/credential_live/form_component.ex", line 552, in anonymous fn/2 in LightningWeb.CredentialLive.FormComponent."form_component (overridable 1)"/1
...
(1 additional frame(s) were not displayed)

(CaseClauseError no case clause matching: %ExJsonSchema.Validator.Error.Format{expected: "hostname"})
stuartc commented 2 months ago

@elias-ba:

    case error do
      %{expected: "uri"} ->
        Changeset.add_error(changeset, field, "expected to be a URI")

      %{any_of: formats} ->

In schema.ex, we don't have a case for %..{expected: "hostname"}, so we could just add a match for that - or change the schema... I'm not sure what the hostname type is, like how do we validate that? Who added the hostname type? Should we care/validate that?