Skip to content

fix: introduce DomainError for invalid domain name (#5044)#5121

Closed
SAY-5 wants to merge 1 commit into
ansys:mainfrom
SAY-5:fix/issue-5044-domain-error
Closed

fix: introduce DomainError for invalid domain name (#5044)#5121
SAY-5 wants to merge 1 commit into
ansys:mainfrom
SAY-5:fix/issue-5044-domain-error

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 11, 2026

Copy link
Copy Markdown

Context

_AllowedDomainNames.valid_name in solution_variables.py raised ZoneError(domain_name=..., allowed_values=...), but ZoneError.__init__ only accepts zone_name. Passing an invalid domain name therefore raised an unrelated TypeError instead of the intended validation error.

Change Summary

  • Add a DomainError class that mirrors ZoneError but uses the domain context in the error message.
  • Switch _AllowedDomainNames.valid_name to raise DomainError.
  • Re-export DomainError from solution_variables_v1 alongside ZoneError.

Rationale

ZoneError keeps its zone-specific signature (back-compatible) and a separate DomainError carries the domain context cleanly, matching the existing pattern.

Impact

Any caller that passes an invalid domain_name to _AllowedDomainNames.valid_name will now receive a clear DomainError with the list of allowed domains, instead of a TypeError. ZoneError behavior is unchanged.

Resolves #5044.

…ames

_AllowedDomainNames.valid_name raised ZoneError(domain_name=...), but
ZoneError.__init__ only accepts zone_name. Passing an invalid domain
name therefore raised TypeError instead of the intended validation
error.

Add a DomainError class that mirrors ZoneError but uses the domain
context, and switch valid_name to raise it. The error message still
flows through allowed_name_error_message with context='domain' so
users see a consistent validation message.

Resolves ansys#5044.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@ansys-cla-bot

ansys-cla-bot Bot commented May 11, 2026

Copy link
Copy Markdown

The following people have not signed the Contributors License Agreement (CLA):

Read the CLA in the link above and sign it by clicking the link below:

You will receive a confirmation as soon as your signature is captured.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@prmukherj

Copy link
Copy Markdown
Collaborator

@SAY-5, this is a nice improvement. Looks good, Thank you.


InvalidSolutionVariableNameError = _v0.InvalidSolutionVariableNameError
ZoneError = _v0.ZoneError
DomainError = _v0.DomainError

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I will cherry-pick this and add test case for this as well and create another PR once we have enough approvals.

@Gobot1234

Copy link
Copy Markdown
Collaborator

This is a duplicate of #5050

@prmukherj

Copy link
Copy Markdown
Collaborator

This is a duplicate of #5050

Right @Gobot1234. Could you please merge that PR and then we can close this as duplicate. Thanks

@prmukherj prmukherj self-requested a review May 12, 2026 10:36
@SAY-5

SAY-5 commented May 12, 2026

Copy link
Copy Markdown
Author

Closing as duplicate of #5050.

@SAY-5 SAY-5 closed this May 12, 2026
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.

TypeError in _AllowedDomainNames.valid_name

3 participants