Skip to content

Add jsonField() resolver - #1317

Open
jsskeen-utah wants to merge 1 commit into
dmno-dev:mainfrom
jsskeen-utah:json-field-resolver
Open

jsskeen-utah wants to merge 1 commit into
dmno-dev:mainfrom
jsskeen-utah:json-field-resolver

Conversation

@jsskeen-utah

@jsskeen-utah jsskeen-utah commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a jsonField(source, path) resolver that picks one field out of a JSON value:

CREDENTIALS=exec(`my-cli export --format=json`)
AWS_ACCESS_KEY_ID=jsonField($CREDENTIALS, "AccessKeyId")
DB_HOST=jsonField($CONFIG, "db.host")

source can be JSON text or any resolver that produces it. path is a dot-separated path with the same rules as the nested-key lookup in awsSecret() and awsParam() (#1291):

  • An exact top-level key with the same name wins, so keys that contain dots still work.
  • Otherwise the path is walked one segment at a time.
  • Object and array results come back as JSON text.

An empty or undefined source resolves to undefined. Invalid JSON, or a missing key, is a resolution error. The error lists the keys available where the path stopped.

The lookup moved from the AWS plugin into packages/utils so the plugin and the core resolver share one implementation. The plugin's behavior does not change.

Testing

  • Linux: the full varlock suite passes (147 files, 2611 tests), including new jsonField() cases for nested paths, exact dotted keys, objects and arrays, empty source, invalid JSON, and a missing key. The packed build also returns the expected values through varlock load.
  • Windows 11: the packed build installs and loads with no errors. Nested paths, object results, a CLI source via PowerShell, and an aws-vault export source all resolve as expected.
  • @env-spec/utils tests pass, including the moved lookup tests.
  • The AWS secrets plugin builds.
  • The new tests use inline JSON strings, so they don't depend on a shell.

Docs

The new section is in reference/functions.mdx, after domainFromUrl().

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: Sound: a core resolver reuses the AWS JSON lookup implementation rather than introducing different path rules.

Reviewed changes cover the resolver, shared utility move, AWS integration, tests, documentation, and release entries.

  • JSON extraction: Adds jsonField(source, path) with nested lookup, exact dotted-key precedence, empty-source handling, and resolution errors.
  • Shared lookup: Moves the helper and its tests into packages/utils, preserving AWS extraction behavior.
  • Documentation and validation: Documents usage and error behavior. All 122 resolver tests and 11 lookup tests passed; the AWS plugin build succeeded.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant