flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

[Bug] SecretsManager get function supports env_var pararmeters.

Open 0yukali0 opened this issue 9 months ago • 12 comments

Tracking issue

flyteorg/flyte#

Why are the changes needed?

In flytekit secretsManager, it will check whether the secret exist in an env var "" or in a file "/etc/secrets//". In flytekit secret, create a env "MY_SECRET" when setting "env_var=MY_SECRET" parameters. SecretManager won't find it with naming rule with "".

What changes were proposed in this pull request?

Adding env_var pararmeters in secreateManager get function. Initially, secretManager search the secret with following orders.

  1. "_" env
  2. "/etc/secrets//" file In this PR, its order will be
  3. "_" env 2 . env_var
  4. "/etc/secrets//" file

How was this patch tested?

make test os.environ["LOCAL_ENV_VAR"] = "value" assert sec.get(group="group", key="key2", env_var="LOCAL_ENV_VAR") == "value" assert sec.get(key="key", env_var="LOCAL_ENV_VAR") == "value" assert sec.get(env_var="LOCAL_ENV_VAR") == "value"

Setup process

Screenshots

Check all the applicable boxes

  • [x] I updated the documentation accordingly.
  • [x] All new and existing tests passed.
  • [x] All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This PR fixes a bug in SecretsManager by adjusting secret lookup order and adding an optional 'env_var' parameter. It includes renaming and reordering variables in the context_manager module with updated type annotations. The changes enhance reliability and clarity of secret management in flytekit.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 1

0yukali0 avatar Mar 18 '25 17:03 0yukali0

Thank you for opening this pull request! 🙌

These tips will help get your PR across the finish line:

  • Most of the repos have a PR template; if not, fill it out to the best of your knowledge.
  • Sign off your commits (Reference: DCO Guide).

welcome[bot] avatar Mar 18 '25 17:03 welcome[bot]

Code Review Agent Run Status

  • Limitations and other issues:  Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

flyte-bot avatar Mar 18 '25 17:03 flyte-bot

Code Review Agent Run Status

  • Limitations and other issues:  Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

flyte-bot avatar Mar 23 '25 16:03 flyte-bot

Code Review Agent Run #2389d5

Actionable Suggestions - 1
  • flytekit/core/context_manager.py - 1
Review Details
  • Files reviewed - 2 · Commit Range: 9503d33..9503d33
    • flytekit/core/context_manager.py
    • tests/flytekit/unit/core/test_context_manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 23 '25 18:03 flyte-bot

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Bug Fix - SecretsManager Bug Fixes

context_manager.py - Refactored SecretsManager by replacing env_var with default_env_var for proper secret lookup and updated type hints.

Testing - SecretsManager Unit Tests Update

test_context_manager.py - Added unit tests to verify the new env_var parameter and secret retrieval order.

flyte-bot avatar Mar 23 '25 18:03 flyte-bot

Code Review Agent Run Status

  • Limitations and other issues:  Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

flyte-bot avatar Mar 24 '25 01:03 flyte-bot

Code Review Agent Run #98d23d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 9503d33..e74db52
    • flytekit/core/context_manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 24 '25 16:03 flyte-bot

/review

0yukali0 avatar Mar 25 '25 09:03 0yukali0

Code Review Agent Run #f74fd8

Actionable Suggestions - 1
  • flytekit/core/context_manager.py - 1
    • Potential undefined variable in error message · Line 435-435
Review Details
  • Files reviewed - 2 · Commit Range: 9503d33..e74db52
    • flytekit/core/context_manager.py
    • tests/flytekit/unit/core/test_context_manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 25 '25 09:03 flyte-bot

/review

0yukali0 avatar Mar 26 '25 15:03 0yukali0

Code Review Agent Run #ba9449

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 33820f9..33820f9
    • flytekit/core/context_manager.py
    • tests/flytekit/unit/core/test_context_manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 26 '25 15:03 flyte-bot

Code Review Agent Run #21673e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 33820f9..33820f9
    • flytekit/core/context_manager.py
    • tests/flytekit/unit/core/test_context_manager.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

Refer to the documentation for additional commands.

Configuration

This repository uses code_review_bito You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

flyte-bot avatar Mar 26 '25 16:03 flyte-bot