Skip to content
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

Support default values for Secrets even if the action context is provided #96

Open
fabioz opened this issue Aug 27, 2024 · 2 comments
Open
Labels
Bug Something isn't working

Comments

@fabioz
Copy link
Contributor

fabioz commented Aug 27, 2024

What is wrong

See: https://sema4ai.slack.com/archives/C0107FK9JR2/p1724759641973369 for details.

Issue: SEMA4AI-VSCODE-X-ACTION-CONTEXT is set from VSCode in any call now (even if there's no OAuth2 info to be passed) and when that's set it'll try to get all the secrets/oauth2 secrets from the context, so, the default values will never be picked up when running from VSCode.

This happens because in sema4ai.actions it doesn't eagerly load the secrets to check if it's valid and just considers that if an action context is available it should always use it (and in this case it turns out that it's invalid).

As a note, the workaround is setting the actual secrets in the devdata/<action_name>.json when running from VSCode (so, not a complete showstopper, but a bit annoying).

System info

Windows, sema4ai-actions 0.10.0

Example script

No response

@fabioz fabioz added the Bug Something isn't working label Aug 27, 2024
@fabioz
Copy link
Contributor Author

fabioz commented Aug 27, 2024

Example failing when running from VSCode (without setting secrets in the json):

@action
def action_with_default_secret(
    my_password: Secret = Secret.model_validate("my-default-secret"),
) -> str:
    """
    This is an action that requires a secret but has a default value for it.
    """
    return my_password.value

@fabioz
Copy link
Contributor Author

fabioz commented Aug 27, 2024

Note: started to create test (which still doesn't reproduce the issue) in the branch issue/96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant