Skip to content

Conversation

@mkundu1
Copy link
Contributor

@mkundu1 mkundu1 commented Dec 11, 2025

Context

Previously, it was possible to access children of inactive objects via builtin class instantiation.

Change Summary

While instantiating builtin classes, use flobject's default getattr to access child objects. That will throw InactiveObjectError from appropriate place.

>>> pyfluent.solver.Viscous(solver)
D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\pyfluent_warnings.py:63: FluentDevVersionWarning: ⚠️ Warning: You are using PyFluent with an unreleased or development version of Fluent.
Compatibility is not guaranteed, and unexpected behavior may occur. Please use a released version of Fluent that is officially supported by this version of PyFluent.
  warnings.warn(
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    import platform
  File "D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\generated\solver\settings_builtin.py", line 272, in __init__
    super().__init__(settings_source=settings_source)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\solver\settings_builtin_bases.py", line 93, in __init__
    _initialize_settings(self, {"settings_source": None}, settings_source, **kwargs)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\solver\settings_builtin_bases.py", line 85, in _initialize_settings
    instance.settings_source = settings_source
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\solver\settings_builtin_bases.py", line 98, in __setattr__
    obj = _get_settings_obj(settings_root, self)
  File "D:\ANSYSDev\PyFluentDev\pyfluent\src\ansys\fluent\core\solver\settings_builtin_bases.py", line 74, in _get_settings_obj
    raise InactiveObjectError(builtin_cls_db_name) from None
ansys.fluent.core.solver.flobject.InactiveObjectError: 'Viscous' is currently inactive.

Rationale

User should not be able to construct children of inactive builtin objects. This conforms with the hierarchical settings API access.

Impact

This will correct the builtin API behaviour.

@github-actions github-actions bot added the bug Issue, problem or error in PyFluent label Dec 11, 2025
@mkundu1 mkundu1 marked this pull request as ready for review December 11, 2025 18:31
Copilot AI review requested due to automatic review settings December 11, 2025 18:31
Copy link
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 a bug where inactive objects could be accessed through builtin class instantiation, bypassing the expected InactiveObjectError. The fix ensures that attempting to instantiate builtin classes for inactive objects (like Viscous when not enabled) properly raises an error, maintaining consistency with the hierarchical settings API.

Key Changes:

  • Modified _get_settings_obj to use standard getattr instead of bypassing the inactive object check
  • Added test coverage to verify that inactive object access raises InactiveObjectError

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/ansys/fluent/core/solver/settings_builtin_bases.py Updated _get_settings_obj to properly propagate InactiveObjectError when accessing inactive objects
tests/test_builtin_settings.py Added test case to verify inactive object access raises expected error
doc/changelog.d/4729.fixed.md Added changelog entry documenting the fix

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

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.

4 participants