feat(python): use environment parameter for multi-url environments in dynamic snippets #10684
+36
−0
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.
Description
Link to Devin run: https://app.devin.ai/sessions/46b6a813ed6c410b81d73d9e41784274
Requested by: Deep Singhvi ([email protected]) (@dsinghvi)
Updates the Python dynamic snippets generator to use the
environmentparameter with the default environment enum value instead ofbase_urlwhen an API has multi-url environments defined.Before:
After:
Changes Made
hasMultipleBaseUrlEnvironments()helper method to detect when an API has multi-url environments from the IRgetDefaultEnvironmentId()helper method to retrieve the default environment ID from the IRgetConstructorEnvironmentArgs()to useenvironmentparameter name when baseUrl is provided AND the API has multi-url environments AND the default environment can be resolved to a valid enum referencegetEnvironmentValue()to return the default environment enum reference instead of a base_url string when the above conditions are metdefaultEnvironmentcannot be resolved to a valid enum reference at any step, the code falls back to using thebase_urlparameter to avoid generating invalid snippetsTesting
The logic appears correct based on code review and local lint checks pass, but this PR should not be merged without validation against actual API definitions.
Human Review Checklist
MUST DO before merge:
pnpm seed:local test --generator python-sdk --fixture multi-url-environmentenvironment=parameter correctlythis.ir.environments.environments.type === "multipleBaseUrls"correctly identifies multi-url environments)Edge cases to test:
pnpm seed:local test --generator python-sdk --fixture single-url-environment-defaultCode review focus areas:
getConstructorEnvironmentArgs()(lines 144-156) correctly handles all casesgetEnvironmentValue()(lines 182-191) is intentional and appropriateRisk Assessment
HIGH RISK: Core functionality is untested against real fixtures. The nested conditional logic could fail silently and fall back to base_url, masking issues. Recommend thorough testing with actual multi-url environment API definitions before merge.