fix(rex): don't expose failed env lookups in the env mapping - #2169
Open
Sanjays2402 wants to merge 2 commits into
Open
fix(rex): don't expose failed env lookups in the env mapping#2169Sanjays2402 wants to merge 2 commits into
Sanjays2402 wants to merge 2 commits into
Conversation
Accessing an undefined variable via env.FOO raises RexUndefinedVariableError, but EnvironmentDict.__getitem__ caches an EnvironmentVariable for that name regardless. A later env.values()/iteration - typically from an unrelated package resolved afterwards - then resolves that cached name and raises a second RexUndefinedVariableError, failing the whole resolve. Filter undefined names out of keys()/__iter__/__len__/__contains__ so the mapping interface only exposes variables that actually exist. Setting the variable later makes it visible again. Adds a regression test covering keys/values/len/contains after a failed lookup. Signed-off-by: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com>
|
Contributor
|
Hello, thanks for the PR submission. We'd like to see CLA's signed before reviewing if possible, because if the CLA is unable to be signed, we are unable to accept the contribution. Hope you understand. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2039
Accessing an undefined variable via
env.FOOraisesRexUndefinedVariableError(expected, catchable), butEnvironmentDict.__getitem__caches anEnvironmentVariablefor that name anyway. A laterenv.values()/iteration — typically from an unrelated package resolved afterwards — resolves the cached name and raises a secondRexUndefinedVariableError, failing the whole resolve.The mapping methods now filter out names that are not actually defined, so a failed lookup leaves no trace; setting the variable later makes it visible again. New
test_11intest_rex.pyfails onmainwith the reported error and passes with the fix.