Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 45
Adding Secrets functionality#149
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1f705c58de165cbe6662e370ebd3bfac89f98673ab1334add15d4f72509db82File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| version = "0.0.7b2" | ||
| version = "0.0.7b3" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| from app.singletons.logs_manager import LogsManager | ||
| from app.models.secrets_response import SecretsResponseModel | ||
| from app.models.db.state import State | ||
| from app.models.db.graph_template_model import GraphTemplate | ||
| from bson import ObjectId | ||
| logger = LogsManager().get_logger() | ||
| async def get_secrets(namespace_name: str, state_id: str, x_exosphere_request_id: str) -> SecretsResponseModel: | ||
| """ | ||
| Get secrets for a specific state. | ||
| Args: | ||
| namespace_name (str): The namespace name | ||
| state_id (str): The state ID | ||
| x_exosphere_request_id (str): Request ID for logging | ||
| Returns: | ||
| SecretsResponseModel: The secrets for the state | ||
| Raises: | ||
| ValueError: If state is not found or graph template is not found | ||
| """ | ||
| try: | ||
| # Get the state | ||
| state = await State.get(ObjectId(state_id)) | ||
| if not state: | ||
| logger.error(f"State {state_id} not found", x_exosphere_request_id=x_exosphere_request_id) | ||
| raise ValueError(f"State {state_id} not found") | ||
| # Verify the state belongs to the namespace | ||
| if state.namespace_name != namespace_name: | ||
| logger.error(f"State {state_id} does not belong to namespace {namespace_name}", x_exosphere_request_id=x_exosphere_request_id) | ||
| raise ValueError(f"State {state_id} does not belong to namespace {namespace_name}") | ||
| # Get the graph template to retrieve secrets | ||
| graph_template = await GraphTemplate.find_one( | ||
| GraphTemplate.name == state.graph_name, | ||
| GraphTemplate.namespace == namespace_name | ||
| ) | ||
| if not graph_template: | ||
| logger.error(f"Graph template {state.graph_name} not found in namespace {namespace_name}", x_exosphere_request_id=x_exosphere_request_id) | ||
| raise ValueError(f"Graph template {state.graph_name} not found in namespace {namespace_name}") | ||
| # Get the secrets from the graph template | ||
| secrets_dict = graph_template.get_secrets() | ||
| logger.info(f"Retrieved {len(secrets_dict)} secrets for state {state_id}", x_exosphere_request_id=x_exosphere_request_id) | ||
| return SecretsResponseModel(secrets=secrets_dict) | ||
| except Exception as e: | ||
| logger.error(f"Error getting secrets for state {state_id}: {str(e)}", x_exosphere_request_id=x_exosphere_request_id) | ||
| raise e | ||
Comment on lines
+54
to
+56
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider improving exception re-raising pattern. While the exception handling logs errors properly, using bare - raise e + raise🤖 Prompt for AI Agents | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.