Skip to content

feat: adding json flag to config:get command#3464

Merged
michaelmalave merged 1 commit into
mainfrom
mm/feat/json-flag-config-get
Jan 13, 2026
Merged

feat: adding json flag to config:get command#3464
michaelmalave merged 1 commit into
mainfrom
mm/feat/json-flag-config-get

Conversation

@michaelmalave

@michaelmalave michaelmalave commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a --json flag to the config:get command that outputs structured JSON, allowing users to distinguish between unset config vars (outputs null) and empty string config vars (outputs ""). This addresses the issue where both cases previously returned empty output, making them indistinguishable. The implementation follows existing patterns in the codebase and maintains full backward compatibility.

Type of Change

  • feat: Introduces a new feature to the codebase (minor semvar update)
  • fix: Bug fix or issue (patch semvar update)
  • perf: Performance improvement
  • docs: Documentation only changes
  • tests: Adding missing tests or correcting existing tests
  • chore: Code cleanup tasks, dependency updates, or other changes

Note: Add a ! after your change type to denote a breaking change.

Testing

Add 2 variables to a new app. One to unset and one as an empty string

# first unset this var
heroku config:unset UNSET_VAR --app safe-dusk-66960

# then run the test commands
./bin/run config:get UNSET_VAR --app safe-dusk-66960 --json
./bin/run config:get EMPTY_STRING_VAR --app safe-dusk-66960 --json

Expected output:
image

Additional Context

Previously, heroku config:get KEY could not distinguish between:

  1. A config var that doesn't exist (unset/removed)
  2. A config var that exists but has an empty string value

Both scenarios returned empty output, making it impossible to determine the actual state. The new --json flag provides structured output:

  • Unset vars: {"key": "KEY", "value": null}
  • Empty string vars: {"key": "KEY", "value": ""}
  • Normal vars: {"key": "KEY", "value": "value"}

For multiple keys, the output is an array of objects. The implementation follows the same pattern as config --json and uses hux.styledJSON() for consistent formatting. Default behavior remains unchanged for backward compatibility.

Related Issue

Closes #3450
W-20875855

@michaelmalave michaelmalave requested a review from a team as a code owner January 13, 2026 00:04

@eablack eablack 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.

nice!

@michaelmalave michaelmalave merged commit 424fc14 into main Jan 13, 2026
8 checks passed
@michaelmalave michaelmalave deleted the mm/feat/json-flag-config-get branch January 13, 2026 16:33
michaelmalave added a commit that referenced this pull request Jan 14, 2026
* chore(deps): bump qs from 6.14.0 to 6.14.1 (#3444)

Bumps [qs](https://github.com/ljharb/qs) from 6.14.0 to 6.14.1.
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](ljharb/qs@v6.14.0...v6.14.1)

---
updated-dependencies:
- dependency-name: qs
  dependency-version: 6.14.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: adding json flag to config:get command (#3464)

adding json flag and applicable tests to handle null and empty string config

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config:get does not distinguish between unset and empty env vars

2 participants