Skip to content

AttributeError: 'HfssConstants' has no attribute 'default_solution' masks the real connection error (constants define solution_default) #8020

Description

@tzhou-yyds

Description

design_solutions.py falls back to self._design_type.default_solution when GetSolutionType() raises, but every constant class in aedt_constants.py defines the attribute as solution_default. The fallback therefore raises AttributeError itself, and that error replaces the original one.

This matters because of when the fallback runs: it is reached exactly when the gRPC connection to AEDT has broken. The user then sees an error naming a design-type constant, which points investigation at design types — where nothing is wrong — instead of at the lost connection, which is the actual failure. It cost us most of a debugging session before we read the source.

The same file uses both spellings, a few lines apart, which is what makes this easy to miss (line numbers from 1.3.0):

# DesignSolution.solution_type getter, line 74 - correct
elif self._odesign:
    try:
        self._solution_type = self._odesign.GetSolutionType()
    except Exception:
        self._solution_type = self._design_type.solution_default   # OK

# DesignSolution.solution_type setter, line 94 - raises
elif self._odesign:
    try:
        self._solution_type = self._odesign.GetSolutionType()
    except Exception:
        self._solution_type = self._design_type.default_solution   # AttributeError

# HFSSDesignSolution.solution_type getter, line 218 - raises
    except Exception:
        self._solution_type = self._design_type.default_solution   # AttributeError

Steps to reproduce

No AEDT installation or licence required:

python -c "from ansys.aedt.core.generic.aedt_constants import HfssConstants as H; print(hasattr(H, 'solution_default'), hasattr(H, 'default_solution'))"

Output on 1.3.0:

True False

Every constant class is affected, not only HfssConstantsQ3dConstants, IcepakConstants, Maxwell3dConstants, CircuitConstants and the rest all define solution_default.

To observe the masking end to end: connect to AEDT over gRPC, cause the session to drop, then read any design property. The AttributeError above is raised instead of a connection error.

Occurrence count

Counting occurrences in src/ansys/aedt/core/application/design_solutions.py:

version solution_default (correct) default_solution (raises)
1.3.0 3 9
1.4.0 1 3
main (2026-08-24) 0 2

The counts fall because the file has been refactored, not because the bug was addressed: the wrong spelling survives in all three, including in HFSSDesignSolution.

Suggested fix

Rename the remaining default_solution accesses to solution_default. The constants themselves need no change.

Separately, chaining the original exception would stop this class of masking regardless of any attribute name:

except Exception as exc:
    raise AedtRuntimeError("lost connection to AEDT") from exc

Which version are you using?

1.3.0 (source of 1.4.0 and main also inspected)

Which operating system are you using?

Windows

What is your Python version?

3.11

Are you using any additional Ansys products?

AEDT 2026 R1, connected over gRPC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions