fix: introduce DomainError for invalid domain name (#5044)#5121
Conversation
…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>
|
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. |
Up to standards ✅🟢 Issues
|
|
@SAY-5, this is a nice improvement. Looks good, Thank you. |
|
|
||
| InvalidSolutionVariableNameError = _v0.InvalidSolutionVariableNameError | ||
| ZoneError = _v0.ZoneError | ||
| DomainError = _v0.DomainError |
There was a problem hiding this comment.
I will cherry-pick this and add test case for this as well and create another PR once we have enough approvals.
|
This is a duplicate of #5050 |
Right @Gobot1234. Could you please merge that PR and then we can close this as duplicate. Thanks |
|
Closing as duplicate of #5050. |
Context
_AllowedDomainNames.valid_nameinsolution_variables.pyraisedZoneError(domain_name=..., allowed_values=...), butZoneError.__init__only acceptszone_name. Passing an invalid domain name therefore raised an unrelatedTypeErrorinstead of the intended validation error.Change Summary
DomainErrorclass that mirrorsZoneErrorbut uses thedomaincontext in the error message._AllowedDomainNames.valid_nameto raiseDomainError.DomainErrorfromsolution_variables_v1alongsideZoneError.Rationale
ZoneErrorkeeps its zone-specific signature (back-compatible) and a separateDomainErrorcarries the domain context cleanly, matching the existing pattern.Impact
Any caller that passes an invalid
domain_nameto_AllowedDomainNames.valid_namewill now receive a clearDomainErrorwith the list of allowed domains, instead of aTypeError.ZoneErrorbehavior is unchanged.Resolves #5044.