Fix credential form crash for array-form JSON Schema type#4678
Merged
Conversation
`Credentials.Schema.get_types/1` assumed each property's `type` was a single string and called `String.to_atom/1` on it directly. JSON Schema draft-07 also allows `type` to be a list (e.g. `["string", "null"]` for nullable fields), which the bundled Browserless schema uses for `baseUrl`. The list reached `String.to_atom/1` and raised an `ArgumentError`, crashing the credential form on render, on validate, and on save. Normalize the property type before atomizing: drop `"null"` from list forms, default to `"string"` if only `"null"` remains, and continue mapping `"object"` to `"map"`. Closes #4647
|
Reviewing the diff. The changes scope to:
This is a pure type-normalization fix in a schema-parsing helper. No DB queries, no web-layer actions, no Repo writes — only string/atom mapping over a JSON Schema map. Security Review ✅
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4678 +/- ##
==========================================
+ Coverage 89.80% 89.86% +0.05%
==========================================
Files 444 444
Lines 21771 21774 +3
==========================================
+ Hits 19552 19567 +15
+ Misses 2219 2207 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Reword changelog so it doesn't claim this PR corrects browserless.json (the schema fix lives in OpenFn/adaptors#1659; priv/schemas/ is gitignored in Lightning). - Add a round-trip Schema.validate/2 test against an array-form `type` schema to prove the full pipeline (cast plus ExJsonSchema) accepts a valid URI and rejects an invalid one.
midigofrank
approved these changes
Apr 30, 2026
theroinaochieng
approved these changes
Apr 30, 2026
This was referenced May 1, 2026
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.
Description
Picking the Browserless type from the credential modal crashes the form on render, change, and save. The credential schema parser couldn't handle JSON Schema's array form for nullable fields (
["string", "null"]), which Browserless uses for the Base URL field. Now it can.The Browserless schema is also internally contradictory (Base URL is
requiredwithminLength: 1, so "null" could never validate). That's fixed upstream in OpenFn/adaptors#1659.Closes #4647
Validation steps
With this branch, open a project's Credentials, click "Add credential", and pick Browserless. The form should render and let you save.
Additional notes for the reviewer
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code):owner,:admin,:editor,:viewer)