Show all variables as undefined when no environment is selected

This commit is contained in:
Pavel Baksy 2025-12-30 16:12:12 +01:00
parent 4b43a509b0
commit 3659543bd2

View File

@ -723,18 +723,27 @@ class RequestTabWidget(Gtk.Box):
def _detect_undefined_variables(self): def _detect_undefined_variables(self):
"""Detect undefined variables in the current request. Returns set of undefined variable names.""" """Detect undefined variables in the current request. Returns set of undefined variable names."""
# Only detect if environment is selected from .variable_substitution import VariableSubstitution
env = self.get_selected_environment()
if not env:
return set()
# Get current request from UI # Get current request from UI
request = self.get_request() request = self.get_request()
# Use VariableSubstitution to detect undefined variables # Get selected environment
from .variable_substitution import VariableSubstitution env = self.get_selected_environment()
_, undefined = VariableSubstitution.substitute_request(request, env)
if not env:
# No environment selected - ALL variables are undefined
# Find all variables in the request
all_vars = set()
all_vars.update(VariableSubstitution.find_variables(request.url))
all_vars.update(VariableSubstitution.find_variables(request.body))
for key, value in request.headers.items():
all_vars.update(VariableSubstitution.find_variables(key))
all_vars.update(VariableSubstitution.find_variables(value))
return all_vars
else:
# Environment selected - find which variables are undefined
_, undefined = VariableSubstitution.substitute_request(request, env)
return undefined return undefined
def _schedule_indicator_update(self): def _schedule_indicator_update(self):