MicrosoftOutlook: Validate entrypoint arguments via Pydantic#2883
MicrosoftOutlook: Validate entrypoint arguments via Pydantic#2883PierrickV wants to merge 1 commit into
Conversation
Reviewer's GuideAdds a shared required-argument validator in the Microsoft Outlook Graph action base and applies it across message actions to guard against missing/empty Sequence diagram for required argument validation in Outlook message actionssequenceDiagram
actor Entrypoint
participant MicrosoftGraphActionBase
participant DeleteMessageAction
Entrypoint->>DeleteMessageAction: run(arguments)
DeleteMessageAction->>MicrosoftGraphActionBase: validate_required_arguments(arguments, required_arguments)
alt [arguments invalid]
MicrosoftGraphActionBase-->>DeleteMessageAction: False
DeleteMessageAction-->>Entrypoint: return None
else [arguments valid]
MicrosoftGraphActionBase-->>DeleteMessageAction: True
DeleteMessageAction->>DeleteMessageAction: access arguments["user"], arguments["message_id"]
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
validate_required_argumentscalls repeat the same{"user": "User", "message_id": "Message id"}mapping in multiple actions; consider extracting this into class-level constants or shared helpers per action type to reduce duplication and make future changes less error-prone. - The new tests for missing
userandmessage_idare quite similar; you could merge them into a single parametrized test that takes the missing field name as a parameter to avoid repeating setup and assertions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `validate_required_arguments` calls repeat the same `{"user": "User", "message_id": "Message id"}` mapping in multiple actions; consider extracting this into class-level constants or shared helpers per action type to reduce duplication and make future changes less error-prone.
- The new tests for missing `user` and `message_id` are quite similar; you could merge them into a single parametrized test that takes the missing field name as a parameter to avoid repeating setup and assertions.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
e03c57f to
0b57c1a
Compare
|
Bumped |
|
Simplified the message action argument models by replacing repeated blank-check field_validator methods with a shared NonEmptyStr Pydantic constraint in microsoft_outlook_modules.models. This keeps the same missing/blank validation behavior with less custom code. I intentionally kept user as a non-empty string because Microsoft Graph accepts either an opaque user object ID or a UPN/email-like value, so EmailStr would wrongly reject valid object IDs. I also kept message_id as a non-empty string because Graph message IDs are opaque identifiers, not UUIDs. I left recipient-like fields as plain strings as well: email-validator is not declared in MicrosoftOutlook/pyproject.toml, so upgrading them to EmailStr here would add a new dependency. |
…ng the action Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
964a2a0 to
37580aa
Compare
What
Validate MicrosoftOutlook's action arguments via Pydantic v2 models before each action runs, so missing/blank required input fails immediately with a clear validation error instead of calling the Graph API with bad data.
Changes
user,message_id→NonEmptyStr(kept as plain non-empty strings —useraccepts either an opaque object ID or a UPN, andmessage_idis an opaque Graph identifier)Testing
pytestandblackpass.