Fortigate: Validate entrypoint arguments via Pydantic#2887
Conversation
Reviewer's GuideAdds early argument validation guards to Fortigate actions to prevent API calls when required entrypoint parameters are missing or empty, covers them with regression tests, and bumps the module patch version with a changelog entry. Sequence diagram for early Fortigate action argument guardssequenceDiagram
actor User
participant FortigateAction
User->>FortigateAction: run(arguments)
alt [missing_or_empty_required_argument]
FortigateAction->>FortigateAction: error
FortigateAction-->>User: return None
else [arguments_valid]
FortigateAction-->>User: proceed with Fortigate API call
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
e1d15c1 to
53814ca
Compare
|
Updated this PR to use native Pydantic v2 end-to-end by upgrading sekoia-automation-sdk to 1.23.1 and aligning the module's Python requirement with the SDK (>=3.11,<3.12). Migrated files:
Validation: pytest (17 passed), mypy passed, black --check passed. |
|
Updated the Fortigate argument models so add_ip_address.ip now uses Pydantics IPvAnyAddress, which preserves the existing non-empty guard and also rejects invalid IP shapes like "not-an-ip" before we build the Fortigate payload. The FQDN and opaque Fortigate object/user names were kept as trimmed non-empty strings because Pydantic core does not provide a built-in FQDN type and those name fields are Fortigate-specific identifiers rather than standard network primitives. |
…action Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c4da5ce to
a865e1c
Compare
What
Validate Fortigate's action arguments via Pydantic v2 models before each action runs, so missing/blank/malformed input fails immediately with a clear validation error instead of calling the API with bad data.
Changes
ip→IPvAnyAddress(add_ip_address)fqdn,name→NonEmptyStr(kept as plain non-empty strings — no built-in stricter Pydantic type exists for FQDNs/object names)Testing
pytestandblackpass.