-
Notifications
You must be signed in to change notification settings - Fork 1
Support usage of environment variables inside robot documentation #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f711c98
Support usage of environment variables inside robot documentation
JokeWaumans c6508da
Use the env variable syntax of robot instead and replace it with the …
JokeWaumans 6dd8a76
Add example env variable
JokeWaumans 2645555
Fix F401 'os' imported but unused
JokeWaumans bf8ee7e
Limit setuptools for testenv:sphinx2.4.5 to fix ModuleNotFoundError: …
JokeWaumans 5f4ec49
Delete newline
JokeWaumans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespace collision risk and unnecessary exposure of all environment variables.
Two concerns with unpacking
**env_varsdirectly into the template keyword arguments:TypeErrorat runtime if any env-var name collides with an existing keyword argument. If an environment variable happens to be namedparser,suite,prefix,gen_matrix,test_type,only,coverages, etc., Python will raiseTypeError: got multiple values for keyword argument '…'. While most standard env vars are uppercase, this is not guaranteed—CI systems and users can define arbitrary names.All environment variables (including secrets) become available to the Mako template. Env vars frequently carry credentials (
AWS_SECRET_ACCESS_KEY,DATABASE_URL, tokens, etc.). Mako templates can execute arbitrary Python, so any template content—including user-supplied.robotdocumentation—could exfiltrate secrets into the generated.rstoutput.Both problems are solved by passing env vars as a single namespaced dict instead of splatting them into the top-level namespace. Templates would then use
${env['MY_VAR']}instead of${MY_VAR}.Proposed fix
Templates would then reference variables as
${env['MY_VAR']}(or${env.get('MY_VAR', 'default')}).🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems valid- but you opted not to take this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 2958
@Letme, you're right to push back on this. After examining the template file, the environment variables aren't even used by the template — which makes this change both risky and unnecessary.Key findings:
The template never references environment variables. The
robot2rst.makotemplate only usessuite,test_type,parser,prefix,relationship_config,gen_matrix, andcoverage. There's no code path that accesses env vars like${MY_VAR}or${env_vars['MY_VAR']}.Environment variable substitution already happens earlier in the pipeline. Looking at the PR changes,
robot_parser.pyalready handles%{VAR}substitution in test documentation strings usingos.environbefore the template is ever rendered. The template'sgenerate_body()function only processesparser.variables, not environment variables.This means exposing all env vars to the template serves no purpose — except creating the exact security and collision risks CodeRabbit flagged.
Recommendation:
Remove the
env_varscode entirely:The PR's environment variable feature already works correctly via the parser layer. Adding them to the template context is dead code that creates security exposure.
🧬 Code Graph Analysis Results
<no_relevant_code_snippets>
</no_relevant_code_snippets>