Skip to content

Conversation

@esebesto
Copy link
Contributor

This PR updates the Azure subscription alias generation logic to exclude invalid characters - specifically commas and spaces.

@github-actions
Copy link

⚠️ This PR modifies code in nise/ but doesn't update the version in nise/__init__.py. Consider bumping the version if this includes functional changes.

@gemini-code-assist
Copy link

Summary of Changes

Hello @esebesto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where generated Azure subscription aliases might contain invalid characters, such as commas and spaces, by implementing a sanitization step. The change ensures that the company_name used in alias generation is cleaned, preventing potential errors or inconsistencies in the Azure environment. This improves the robustness of the alias generation logic without altering the core functionality of how the account information is retrieved.

Highlights

  • Azure Alias Sanitization: The pull request introduces changes to sanitize Azure subscription aliases by removing invalid characters from the generated company names.
  • Character Removal: Specifically, commas are now removed from the company_name string, and spaces are replaced with underscores to ensure alias validity.
  • Affected Function: These sanitization rules are applied within the _generate_azure_account_info function in nise/report.py.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@esebesto esebesto changed the title [COST-6915] - Sanitize Azure subscription aliases to remove invalid c… [COST-6915] - Remove invalid characters from Azure subscription aliases Nov 18, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to sanitize Azure subscription aliases by removing commas and replacing spaces with underscores. While the change correctly sanitizes the company_name for the alias, it introduces a side-effect bug where the company_email is generated with an invalid domain name containing underscores. I've added a comment with a suggested fix to address this issue by reordering the operations and improving the code.

@esebesto
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to sanitize Azure subscription aliases by removing invalid characters like spaces and commas from the company name. The implementation correctly replaces spaces with underscores but introduces a critical bug when attempting to remove commas. The replace() method is called with only one argument, which will result in a TypeError. I've provided a suggestion to fix this issue. The rest of the changes correctly apply the sanitized name.

@esebesto
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses the issue of invalid characters (commas and spaces) in Azure subscription aliases by introducing a sanitized company name. The changes are clear and well-targeted. I have one suggestion to use a potentially more efficient method for string sanitization.

"""Return Azure subscription, billing, and usage account info."""
fake = Faker()
company_name = fake.company()
company_name_sanitized = company_name.replace(" ", "_").replace(",", "")

Choose a reason for hiding this comment

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

medium

For sanitizing the company name, you can use str.translate() which can be more efficient and concise when dealing with multiple character replacements or deletions. It performs all transformations in a single pass over the string.

Suggested change
company_name_sanitized = company_name.replace(" ", "_").replace(",", "")
company_name_sanitized = company_name.translate(str.maketrans(" ", "_", ","))

@esebesto
Copy link
Contributor Author

/retest

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.6%. Comparing base (6691e81) to head (74d5884).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #595     +/-   ##
=======================================
+ Coverage   93.5%   93.6%   +0.1%     
=======================================
  Files         56      56             
  Lines       4730    4731      +1     
  Branches     663     663             
=======================================
+ Hits        4422    4426      +4     
+ Misses       165     164      -1     
+ Partials     143     141      -2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@esebesto esebesto merged commit 511ef94 into main Nov 19, 2025
5 checks passed
@esebesto esebesto deleted the esebesto/fix_azure_subscriptions branch November 19, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants