Show all variables as undefined when no environment is selected

This commit is contained in:
vesp 2025-12-30 16:12:12 +01:00
parent 3a903f28ec
commit 80fe2a33f0

View File

@ -723,18 +723,27 @@ class RequestTabWidget(Gtk.Box):
def _detect_undefined_variables(self):
"""Detect undefined variables in the current request. Returns set of undefined variable names."""
# Only detect if environment is selected
env = self.get_selected_environment()
if not env:
return set()
from .variable_substitution import VariableSubstitution
# Get current request from UI
request = self.get_request()
# Use VariableSubstitution to detect undefined variables
from .variable_substitution import VariableSubstitution
_, undefined = VariableSubstitution.substitute_request(request, env)
# Get selected environment
env = self.get_selected_environment()
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
def _schedule_indicator_update(self):