You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #54, the new handle_qa_review handler parses raw SharePoint item_fields dicts into a typed Pydantic model (SharepointInvitationQA) as its first step, using from_sharepoint_fields(). This gives us:
Pydantic validation up front (catches malformed data early)
SharePoint system fields (Modified, Created, AuthorLookupId, etc.) stripped automatically
Typed attribute access instead of .get() calls with default strings
Consistent serialisation when writing back via to_sharepoint_fields()
The existing make_list_review_handler (handle_review) and extract_actions_from_review still work with raw item_fields dicts throughout. This means:
No validation of incoming SharePoint data
Manual .get() calls with hardcoded defaults scattered across handler and component code
Risk of passing system fields through to downstream consumers
Proposal
Adopt the same pattern for the existing handlers:
handle_review in route_handlers.py — parse item_fields into the appropriate SharePoint model (SharepointInvitation or SharepointSubmission depending on document_type) as the first step
extract_actions_from_review in components.py — accept a typed model instead of a raw dict, build context strings from model attributes rather than .get() calls
to_sharepoint_action in mappers.py — accept a typed source model instead of item_fields: dict
This would make from_sharepoint_fields() the standard entry point for all SharePoint data entering the handler pipeline.
Files affected
src/box2/receiver/route_handlers.py — handle_review inner function
Context
In #54, the new
handle_qa_reviewhandler parses raw SharePointitem_fieldsdicts into a typed Pydantic model (SharepointInvitationQA) as its first step, usingfrom_sharepoint_fields(). This gives us:Modified,Created,AuthorLookupId, etc.) stripped automatically.get()calls with default stringsto_sharepoint_fields()The existing
make_list_review_handler(handle_review) andextract_actions_from_reviewstill work with rawitem_fieldsdicts throughout. This means:.get()calls with hardcoded defaults scattered across handler and component codeProposal
Adopt the same pattern for the existing handlers:
handle_reviewinroute_handlers.py— parseitem_fieldsinto the appropriate SharePoint model (SharepointInvitationorSharepointSubmissiondepending ondocument_type) as the first stepextract_actions_from_reviewincomponents.py— accept a typed model instead of a raw dict, build context strings from model attributes rather than.get()callsto_sharepoint_actioninmappers.py— accept a typed source model instead ofitem_fields: dictThis would make
from_sharepoint_fields()the standard entry point for all SharePoint data entering the handler pipeline.Files affected
src/box2/receiver/route_handlers.py—handle_reviewinner functionsrc/box2/pipeline/components.py—extract_actions_from_review(), context template formattingsrc/box2/pipeline/mappers.py—to_sharepoint_action()signatureNotes
from_sharepoint_fieldsutility and round-trip tests already exist from feat: add private office QA stage for invitations #54