Skip to content

Conversation

@lhhyung
Copy link
Member

@lhhyung lhhyung commented Jul 10, 2025

Category

  • New feature
  • Bug fix
  • Improvement
  • Refactor
  • etc

Description

Prevent error when multiple secrets exist with collect_scope=subscription_id

Known issue

@lhhyung lhhyung requested a review from Copilot July 10, 2025 04:03
@lhhyung lhhyung self-assigned this Jul 10, 2025
@lhhyung lhhyung added enhancement New feature or request pass/signedoff labels Jul 10, 2025
@lhhyung lhhyung merged commit 805707b into cloudforet-io:master Jul 10, 2025
0 of 2 checks passed
@github-actions
Copy link

⚠️ @lhhyung the signed-off-by was not found in the following 2 commits:

  • d1e8a7d: fix: Prevent error when multiple secrets exist with collect_scope=subscription_id
  • 03cc020: Merge branch 'cloudforet-io:master' into master

✅ Why it is required

The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the DCO.

Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.

This is my commit message

Signed-off-by: Random Developer <randomdeveloper@example.com>

Git even has a -s command line option to append this automatically to your commit message:

$ git commit -s -m 'This is my commit message'

1 similar comment
@github-actions
Copy link

⚠️ @lhhyung the signed-off-by was not found in the following 2 commits:

  • d1e8a7d: fix: Prevent error when multiple secrets exist with collect_scope=subscription_id
  • 03cc020: Merge branch 'cloudforet-io:master' into master

✅ Why it is required

The Developer Certificate of Origin (DCO) is a lightweight way for contributors to certify that they wrote or otherwise have the right to submit the code they are contributing to the project. Here is the full text of the DCO.

Contributors sign-off that they adhere to these requirements by adding a Signed-off-by line to commit messages.

This is my commit message

Signed-off-by: Random Developer <randomdeveloper@example.com>

Git even has a -s command line option to append this automatically to your commit message:

$ git commit -s -m 'This is my commit message'

Copy link

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 refactors the secret selection logic to avoid errors when billing_tenant_id is missing and multiple secrets exist under collect_scope=subscription_id.

  • Replaced direct indexing of billing_tenant_id with dict.get() to prevent KeyError.
  • Removed redundant local variable and streamlined the lookup loop.
Comments suppressed due to low confidence (1)

src/cloudforet/cost_analysis/main.py:206

  • Add a unit test for the case where multiple secrets exist and billing_tenant_id is not set, verifying that the fallback to subscription_id branch is exercised without error.
        if _secret_data["tenant_id"] == task_options.get("billing_tenant_id"):

Comment on lines 205 to +206
for _secret_data in secrets:
if _secret_data["tenant_id"] == billing_tenant_id:
if _secret_data["tenant_id"] == task_options.get("billing_tenant_id"):
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

[nitpick] Cache task_options.get("billing_tenant_id") in a local variable before the loop to avoid repeated dictionary lookups and improve readability.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pass/signedoff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant