Skip to content

Fix TypeError in _AllowedDomainNames.valid_name#5048

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-typeerror-valid-name
Closed

Fix TypeError in _AllowedDomainNames.valid_name#5048
Copilot wants to merge 2 commits intomainfrom
copilot/fix-typeerror-valid-name

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

_AllowedDomainNames.valid_name raised a TypeError at runtime because it called ZoneError(domain_name=..., ...), but ZoneError.__init__ only accepts zone_name as its identifier parameter.

Context

ZoneError signature is __init__(self, zone_name: str, allowed_values: List[str]). Passing domain_name= as a keyword argument always fails with TypeError: unexpected keyword argument 'domain_name', making any invalid domain name produce a confusing secondary error instead of the intended validation message.

Change Summary

  • Added DomainError(ValueError) class mirroring ZoneError but typed for domain context (domain_name parameter, "domain" error context string)
  • Updated _AllowedDomainNames.valid_name to raise DomainError instead of ZoneError
# Before — raises TypeError
raise ZoneError(domain_name=domain_name, allowed_values=self())

# After — raises DomainError with correct message
raise DomainError(domain_name=domain_name, allowed_values=self())
# e.g. "'domain' has no attribute 'bad-domain'. The allowed values are: ['mixture']"

Rationale

Creating a dedicated DomainError is cleaner than patching ZoneError to accept both parameter names, keeps error types semantically distinct (callers can catch DomainError vs ZoneError independently), and matches the existing pattern used by InvalidSolutionVariableNameError.

Impact

_AllowedDomainNames.valid_name — previously always threw TypeError on an invalid domain name; now correctly raises DomainError with an informative message listing allowed domain names.

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
2 tasks
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 2, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Copilot AI changed the title [WIP] Fix TypeError in _AllowedDomainNames.valid_name Fix TypeError in _AllowedDomainNames.valid_name Apr 2, 2026
Copilot AI requested a review from Gobot1234 April 2, 2026 13:25
@Gobot1234 Gobot1234 marked this pull request as ready for review April 2, 2026 13:30
Copilot AI review requested due to automatic review settings April 2, 2026 13:30
@Gobot1234 Gobot1234 requested a review from mayankansys as a code owner April 2, 2026 13:30
@github-actions github-actions bot added the bug Issue, problem or error in PyFluent label Apr 2, 2026
Copy link
Copy Markdown
Contributor

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 fixes runtime validation of invalid domain names in the solution variables service by replacing an incorrect ZoneError(domain_name=...) raise (which caused a TypeError) with a dedicated DomainError that formats the intended allowed-name message.

Changes:

  • Introduced DomainError(ValueError) for invalid domain-name contexts.
  • Updated _AllowedDomainNames.valid_name to raise DomainError instead of misusing ZoneError.
  • Updated the corresponding docstring in _AllowedDomainNames.valid_name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 441 to 445
if not self.is_valid(domain_name):
raise ZoneError(
raise DomainError(
domain_name=domain_name,
allowed_values=self(),
)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Consider adding a regression test for this behavior (e.g., calling SolutionVariableInfo.get_variables_info(..., domain_name="bad")) asserting that an invalid domain now raises DomainError (and that the message includes the allowed domain list). This would prevent the prior TypeError regression from reappearing.

Copilot uses AI. Check for mistakes.
Copilot AI added a commit that referenced this pull request Apr 2, 2026
@Gobot1234
Copy link
Copy Markdown
Collaborator

Closing this in favour of #5050

@Gobot1234 Gobot1234 closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue, problem or error in PyFluent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError in _AllowedDomainNames.valid_name

3 participants