mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5439] [MERGED] fix(js-sandbox): resolve environment variable fallback behavior #5207
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5439
Author: @chhaviG22
Created: 10/3/2025
Status: ✅ Merged
Merged: 10/28/2025
Merged by: @jamesgeorge007
Base:
next← Head:fix/env-var-fallback📝 Commits (5)
96cf152fix: fallback to initialValue for environment vars with empty currentValue in pre/post-request scripts4ff8ee9Update packages/hoppscotch-js-sandbox/src/utils/shared.ts6317fceUpdate packages/hoppscotch-js-sandbox/src/utils/shared.ts5c5b402chore: cleanupaf1ad0bchore: improve fallback logic and add comprehensive test coverage📊 Changes
4 files changed (+1005 additions, -34 deletions)
View changed files
➕
packages/hoppscotch-js-sandbox/src/__tests__/combined/env-fallback-behavior.spec.ts(+864 -0)📝
packages/hoppscotch-js-sandbox/src/cage-modules/utils/base-inputs.ts(+6 -0)📝
packages/hoppscotch-js-sandbox/src/types/index.ts(+64 -9)📝
packages/hoppscotch-js-sandbox/src/utils/shared.ts(+71 -25)📄 Description
Closes #5437
This PR addresses the issue where environment variables with empty currentValue don't fall back to their initialValue in pre-request or post-request scripts. It ensures that the correct value is returned as expected.
What's Changed
initialValuewhencurrentValueis empty or unset.initialValueandcurrentValueare not set.SandboxEnvironmentVariableto distinguish between internal sandbox types (which can be arrays/objects/primitives) and the external API boundary (which always uses strings).Notes to Reviewers
Check the fallback behaviour for environment variables with both
initialValueand an emptycurrentValue.Review the changes made in the REST tab to confirm correct functionality for pre/post-request scripts.
The type system changes are purely for clarity - they separate the internal sandbox representation (which can hold complex types for
pmnamespace compatibility) from the external API (which serialises everything to strings). No functional changes to the type system, just better documentation.Let me know if there are any additional edge cases to cover or feedback to address.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.