📦 ANTA version
📝 Details
Summary
AntaTest._init_inputs() only handles None, dict, and AntaTest.Input. If a caller passes any other top-level type, such as str or list, the framework does not reject it explicitly. Instead, the test object can remain partially initialized and fail later with misleading runtime errors such as AttributeError.
This is primarily a Python/package API robustness bug. It is not normally hit through the standard anta nrfu catalog-file workflow, because catalog parsing validates input shape earlier.
Evidence
models.py (line 475): _init_inputs() only handles:None
- AntaTest.Input
- dict
- Any other type falls through silently without:setting self.inputs
- marking the test result as error
Impact
Invalid package/API usage is not rejected at the framework boundary. Instead of a clear validation error, users get a later runtime failure that is harder to debug.
Steps To Reproduce
import asyncio
from typing import ClassVar
from anta.device import AsyncEOSDevice
from anta.models import AntaTest
class FakeTestWithInput(AntaTest):
categories: ClassVar[list[str]] = []
commands: ClassVar[list] = []
class Input(AntaTest.Input):
string: str
@AntaTest.anta_test
def test(self) -> None:
self.result.is_success(self.inputs.string)
device = AsyncEOSDevice(
host="device.example.com",
username="admin",
password="admin",
name="device",
disable_cache=True,
)
test = FakeTestWithInput(device=device, inputs="wrong-type")
asyncio.run(test.test())
print(test.result.result)
print(test.result.messages)
Expected
The framework should reject the invalid input type immediately with a clear error.
Actual
The test is created without valid inputs and later fails with a runtime error such as:
AttributeError: 'FakeTestWithInput' object has no attribute 'inputs'
Proposed Fix
Add an explicit else branch in _init_inputs() to reject unsupported top-level input types and mark the result as error with a clear message.
📦 ANTA version
anta, version 1.9.0📝 Details
Summary
AntaTest._init_inputs() only handles None, dict, and AntaTest.Input. If a caller passes any other top-level type, such as str or list, the framework does not reject it explicitly. Instead, the test object can remain partially initialized and fail later with misleading runtime errors such as AttributeError.
This is primarily a Python/package API robustness bug. It is not normally hit through the standard anta nrfu catalog-file workflow, because catalog parsing validates input shape earlier.
Evidence
models.py (line 475): _init_inputs() only handles:None
Impact
Invalid package/API usage is not rejected at the framework boundary. Instead of a clear validation error, users get a later runtime failure that is harder to debug.
Steps To Reproduce
Expected
The framework should reject the invalid input type immediately with a clear error.
Actual
The test is created without valid inputs and later fails with a runtime error such as:
AttributeError: 'FakeTestWithInput' object has no attribute 'inputs'
Proposed Fix
Add an explicit else branch in _init_inputs() to reject unsupported top-level input types and mark the result as error with a clear message.