Skip to content

Resolve environment variables in dev bundle addon paths#1429

Merged
iLLiCiTiT merged 4 commits intodevelopfrom
enhancement/use-env-vars-in-dev-bundle-paths
Sep 9, 2025
Merged

Resolve environment variables in dev bundle addon paths#1429
iLLiCiTiT merged 4 commits intodevelopfrom
enhancement/use-env-vars-in-dev-bundle-paths

Conversation

@antirotor
Copy link
Copy Markdown
Member

@antirotor antirotor commented Sep 8, 2025

Changelog Description

Add support of resolution of environment variables in dev bundle addon paths. You can use standard {FOO_BAR} format within the path. This can be used to set dev bundle to work on multiple platforms provided the environment variable is set there.

Additional info

This also needs PR in ayon-launcher ynput/ayon-launcher#253

Testing notes:

  1. In dev bundle, set path to addons like {DEV_ADDONS}/ayon-core/client
  2. Set this environment variable so the path exist and can be resolved
  3. Run AYON

@antirotor antirotor self-assigned this Sep 8, 2025
@antirotor antirotor added the type: enhancement Improvement of existing functionality or minor addition label Sep 8, 2025
@ynbot ynbot added the size/XS label Sep 8, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for environment variable resolution in dev bundle addon paths using the standard {VAR_NAME} format. This allows dev bundles to work across multiple platforms by resolving environment variables at runtime.

  • Adds environment variable resolution to dev addon paths using string format syntax
  • Enables cross-platform compatibility for dev bundles through environment variable substitution

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if use_dev_path:
addon_dir = dev_addon_info["path"]
if addon_dir:
addon_dir = addon_dir.format(**os.environ)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using str.format(**os.environ) with user-controlled input can be unsafe as it exposes all environment variables and could lead to format string injection attacks. Consider using os.path.expandvars() instead, which safely expands environment variables in the $VAR or ${VAR} format, or implement a safer custom formatter that only allows specific variable patterns.

Suggested change
addon_dir = addon_dir.format(**os.environ)
addon_dir = os.path.expandvars(addon_dir)

Copilot uses AI. Check for mistakes.
Comment on lines +305 to +306
if addon_dir:
addon_dir = addon_dir.format(**os.environ)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code will raise a KeyError if the path contains environment variable placeholders that don't exist in os.environ. Consider wrapping this in a try-except block or using a safer method like string.Template.safe_substitute() to handle missing variables gracefully.

Copilot uses AI. Check for mistakes.
@ynbot ynbot moved this to Review In Progress in PR reviewing Sep 8, 2025
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Review In Progress to Merge Requested in PR reviewing Sep 9, 2025
@iLLiCiTiT iLLiCiTiT merged commit 85c82a2 into develop Sep 9, 2025
4 checks passed
@iLLiCiTiT iLLiCiTiT deleted the enhancement/use-env-vars-in-dev-bundle-paths branch September 9, 2025 07:38
@github-project-automation github-project-automation bot moved this from Merge Requested to Done in PR reviewing Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS type: enhancement Improvement of existing functionality or minor addition

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants