[PR #5616] [MERGED] fix(common): environment variables not detected in request body editors #5283

Closed
opened 2026-03-17 02:44:44 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5616
Author: @chhaviG22
Created: 11/25/2025
Status: Merged
Merged: 12/9/2025
Merged by: @jamesgeorge007

Base: patchHead: fix/env-variable-detection-request-body


📝 Commits (7)

  • 7305bd5 fix: environment variables not detected in request body editors
  • 1a97381 Merge branch 'main' into fix/env-variable-detection-request-body
  • ce2da25 fix: variables reactivity issue
  • d6d1b7f chore: cleanup
  • df4139f chore: cleanup
  • 6ba776a fix: collection var value bug
  • 6d017b4 chore: reset inherited properties on delete

📊 Changes

3 files changed (+62 additions, -24 deletions)

View changed files

📝 packages/hoppscotch-common/src/components/collections/index.vue (+6 -0)
📝 packages/hoppscotch-common/src/helpers/collection/collection.ts (+6 -0)
📝 packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts (+50 -24)

📄 Description

This PR fixes an issue where environment variables were not being detected and highlighted in request body editors (JSON, XML, GraphQL, etc.), while they worked correctly in the URL/endpoint field.

Problem

  • Environment variables using the <<variable>> syntax were not being recognized in request body editors
  • Variable highlighting and tooltips were not appearing in body content
  • This inconsistency affected the user experience when working with environment variables across different parts of the request

Solution

Updated the HoppEnvironment.ts CodeMirror extension to properly handle environment variable detection and highlighting in request body editors by:

  • Fixed the environment variable aggregation logic to include request and collection variables
  • Ensured the environment plugin correctly subscribes to and processes environment changes
  • Improved the reactivity of environment variable detection across all editor contexts

What's Changed

  • Modified HoppEnvironmentPlugin class in packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts
  • Enhanced environment variable resolution for request body contexts

Impact

  • Environment variables now work consistently across URL fields and request body editors
  • Variable tooltips and highlighting function properly in all editor contexts
  • Improved developer experience when using environment variables in requests

Testing

  • Verified environment variables are detected in JSON request bodies
  • Confirmed variables work in XML request bodies
  • Ensured URL field variables continue to work as expected

Summary by cubic

Fixes environment variables not being detected and highlighted in request body editors (JSON, XML, GraphQL). Updates the HoppEnvironment CodeMirror plugin to correctly aggregate request, collection, and environment variables across editor contexts.

  • Bug Fixes
    • Safely aggregate request and collection variables, even when inheritedProperties is undefined or cleared on delete.
    • Recompute variables on environment stream updates and tab changes to avoid stale values.
    • Show correct current values in tooltips for request and collection variables.

Written for commit 6d017b4038. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5616 **Author:** [@chhaviG22](https://github.com/chhaviG22) **Created:** 11/25/2025 **Status:** ✅ Merged **Merged:** 12/9/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `fix/env-variable-detection-request-body` --- ### 📝 Commits (7) - [`7305bd5`](https://github.com/hoppscotch/hoppscotch/commit/7305bd51f6a5d00f7af42abf4c0a598f0b59ace8) fix: environment variables not detected in request body editors - [`1a97381`](https://github.com/hoppscotch/hoppscotch/commit/1a973811aaabe96d854c0cd65b0f5429a0dee07a) Merge branch 'main' into fix/env-variable-detection-request-body - [`ce2da25`](https://github.com/hoppscotch/hoppscotch/commit/ce2da251fa66c2b21274c713c6ec6e4c0d7fc211) fix: variables reactivity issue - [`d6d1b7f`](https://github.com/hoppscotch/hoppscotch/commit/d6d1b7f66490436a59b8b971552aa672eb12228c) chore: cleanup - [`df4139f`](https://github.com/hoppscotch/hoppscotch/commit/df4139f24817ad723615cc2a061ea1afb33b9c14) chore: cleanup - [`6ba776a`](https://github.com/hoppscotch/hoppscotch/commit/6ba776aea1ec4f22934fef2f6d4fd877ba45f07c) fix: collection var value bug - [`6d017b4`](https://github.com/hoppscotch/hoppscotch/commit/6d017b4038160f247319e9d5c0199196cb4c608b) chore: reset inherited properties on delete ### 📊 Changes **3 files changed** (+62 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/components/collections/index.vue` (+6 -0) 📝 `packages/hoppscotch-common/src/helpers/collection/collection.ts` (+6 -0) 📝 `packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts` (+50 -24) </details> ### 📄 Description This PR fixes an issue where environment variables were not being detected and highlighted in request body editors (JSON, XML, GraphQL, etc.), while they worked correctly in the URL/endpoint field. ## Problem - Environment variables using the `<<variable>>` syntax were not being recognized in request body editors - Variable highlighting and tooltips were not appearing in body content - This inconsistency affected the user experience when working with environment variables across different parts of the request ## Solution Updated the `HoppEnvironment.ts` CodeMirror extension to properly handle environment variable detection and highlighting in request body editors by: - Fixed the environment variable aggregation logic to include request and collection variables - Ensured the environment plugin correctly subscribes to and processes environment changes - Improved the reactivity of environment variable detection across all editor contexts ## What's Changed - Modified `HoppEnvironmentPlugin` class in `packages/hoppscotch-common/src/helpers/editor/extensions/HoppEnvironment.ts` - Enhanced environment variable resolution for request body contexts ## Impact - ✅ Environment variables now work consistently across URL fields and request body editors - ✅ Variable tooltips and highlighting function properly in all editor contexts - ✅ Improved developer experience when using environment variables in requests ## Testing - [x] Verified environment variables are detected in JSON request bodies - [x] Confirmed variables work in XML request bodies - [x] Ensured URL field variables continue to work as expected <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes environment variables not being detected and highlighted in request body editors (JSON, XML, GraphQL). Updates the HoppEnvironment CodeMirror plugin to correctly aggregate request, collection, and environment variables across editor contexts. - **Bug Fixes** - Safely aggregate request and collection variables, even when inheritedProperties is undefined or cleared on delete. - Recompute variables on environment stream updates and tab changes to avoid stale values. - Show correct current values in tooltips for request and collection variables. <sup>Written for commit 6d017b4038160f247319e9d5c0199196cb4c608b. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:44:44 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5283
No description provided.