TrendMicroVisionOne: Validate entrypoint arguments via Pydantic#2885
TrendMicroVisionOne: Validate entrypoint arguments via Pydantic#2885PierrickV wants to merge 1 commit into
Conversation
Reviewer's GuideAdds shared required-argument validation to TrendMicro VisionOne actions so missing or empty entrypoint arguments short‑circuit execution before any HTTP/API calls, and backfills regression tests plus versioning/changelog updates. Sequence diagram for required-argument guard in TrendMicroVisionOne actionssequenceDiagram
actor Orchestrator
participant AddAlertNoteAction
participant TrendMicroVisionOneBaseAction
Orchestrator->>AddAlertNoteAction: run(arguments)
AddAlertNoteAction->>TrendMicroVisionOneBaseAction: get_required_argument(arguments, alert_id, "Alert ID is required")
alt [missing_or_empty_alert_id]
TrendMicroVisionOneBaseAction->>AddAlertNoteAction: error("Alert ID is required")
AddAlertNoteAction-->>Orchestrator: return None
else [alert_id_present]
AddAlertNoteAction->>TrendMicroVisionOneBaseAction: get_required_argument(arguments, note, "Note is required")
alt [missing_or_empty_note]
TrendMicroVisionOneBaseAction->>AddAlertNoteAction: error("Note is required")
AddAlertNoteAction-->>Orchestrator: return None
else [note_present]
AddAlertNoteAction-->>Orchestrator: [HTTP_request_and_followup]
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The generic
get_required_argumenthelper relies on a truthiness check, which may inadvertently reject valid falsy values in future (e.g.,0orFalse); consider making the validation explicit per expected type (string empty, list length, etc.) or allowing callers to pass a predicate. - For arguments that are conceptually lists like
agent_guids, the helper currently only guards against empty values; if individual GUIDs must also be non-empty strings, consider adding a simple element-level validation to avoid silently accepting invalid entries.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The generic `get_required_argument` helper relies on a truthiness check, which may inadvertently reject valid falsy values in future (e.g., `0` or `False`); consider making the validation explicit per expected type (string empty, list length, etc.) or allowing callers to pass a predicate.
- For arguments that are conceptually lists like `agent_guids`, the helper currently only guards against empty values; if individual GUIDs must also be non-empty strings, consider adding a simple element-level validation to avoid silently accepting invalid entries.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1017290 to
ff9bf29
Compare
|
Updated this PR to complete the native Pydantic v2 migration for TrendMicroVisionOne.
There are no remaining |
|
Updated the TrendMicroVisionOne action argument models to use native Pydantic constraints instead of custom validators. In particular, agent_guids is now typed as list[UUID] with min_length=1, and agent_guid is now a UUID, which preserves the non-empty requirement and adds real UUID-shape validation. I kept alert_id, note, and file_path as trimmed non-empty strings because the fixtures show those are opaque, free-text, or path values rather than UUIDs, and simplified process_id to a native gt=0 numeric constraint. |
|
Consolidated the CHANGELOG: merged the two stacked version entries ( |
…nning the action Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3148fa7 to
b445498
Compare
What
Validate TrendMicroVisionOne'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
agent_guids→list[UUID]withField(min_length=1)agent_guid→UUIDprocess_id→Field(gt=0)alert_id,note,file_path→NonEmptyStrTesting
pytestandblackpass.