feat(connectors): config models check the design's field formats (Drive, Microsoft, Notion)
Description
Backend PR for the connector checks redesign, stacked on #16211. This is the second half of the format-rule work. The Google Drive, SharePoint, OneDrive and Notion config models check the design's field formats. It uses the same pattern as the Atlassian and GitHub PR: a field validator in each config.py raises field_format_error with the design's line.
Rules (field validators in each config.py)
| Connector | Field | Rejects | Message (the design's line) |
|---|---|---|---|
| Google Drive | my_drive_emails | a value of only commas or spaces | Enter at least one email. |
| SharePoint | sites | an entry that is not https:// with /sites/, /teams/ or /personal/ (blank entries too) | Enter a full site URL, e.g. https://acme.sharepoint.com/sites/hr. |
| OneDrive | users | a non-blank entry that is not an email | Enter email addresses, e.g. jane@acme.com. |
| Notion | root_page_id | a value that is not a 32-character ID (with or without dashes) or a Notion page URL | Paste the page URL or its 32-character ID. |
- Notion page URLs. The design's line tells the admin to paste the page URL. So the validator changes a Notion page URL to the page ID that it holds. The connector and the checks get the ID. The URL parser moved from
NotionConnector.normalize_urltonotion/config.py, andnormalize_urlcalls it. - One source for each rule. The SharePoint rule uses
is_site_url_well_formed, which moved fromconnector_utils.pytosharepoint/config.py. The config modules load at import of the registry, andconnector_utils.pyloads the Office 365 client. The OneDrive rule uses the email parse ofnormalize_configured_users(new helpernormalized_user_email). - Removed check code. A check cannot run while its field is invalid, so this code could not run: the Drive "My Drive Emails has no email" branch, the SharePoint "Not a site URL" branch, and the OneDrive "Not an email address" branch.
Not in this PR (the design's other field rules for these connectors):
- Slack "Channels, Channels to Exclude" regex: the design puts this rule on the server (
where: server). It also depends on a second field (the regex toggle), and a config model must not have model validators. The "Compile channel patterns" check keeps it. - Google Drive "Primary Admin Email": a credential field, not a config field.
- Google Drive "My Drive Emails, Specific User Emails" for OAuth, and SharePoint "Graph API Host, Authority Host": the design hides these fields ("No error"). The single Microsoft cloud dropdown is its own PR, because it needs a frontend field.
- SharePoint "Select at least one: Index Documents or Index ASPX Sites": this rule reads two fields. The "Check selected content" check keeps it.
- Outlook: the design gives no field rule.
Stored connectors. A stored config that breaks a rule still indexes as before: build_connector_kwargs uses the stored config as-is, and logs a warning. Its stored check runs fail the config-reading checks as invalid settings. An edit that changes the config must fix the field. For OneDrive, a non-email entry already stopped the connector at start. A stored Notion page URL now indexes the root page; before, the connector sent the URL to Notion as an ID, and the root page read failed.
How Has This Been Tested?
test_draft_plan_format_rules.py:/plangives each new rule's message on its field. Create and edit validation reject the same values. Valid values (IDs with spaces, dashed IDs, page URLs, blank entries, blank values) give no error. A Notion page URL reaches the connector as its page ID.- Existing Drive, SharePoint, OneDrive and Notion check tests updated: an invalid field fails the check as an invalid setting, without a request. The Notion tests use a real-shaped page ID. A new Notion test reads the page by the ID in a page URL. The 400 "Root page ID is not valid" row stays, for an ID that Notion still rejects.
- The daily live tests send no value that a new rule rejects, so they did not change. I did not run them.
- Connector and server unit tests: 7013 passed, 1 failed. The failure (
test_browser_lifecycle.py::test_download_is_not_retried_and_does_not_relaunch_browser) also fails on the stack tip without this PR.tyand pre-commit are clean.
Additional Options
- [Optional] Please cherry-pick this PR to the latest release version.
- [Optional] Override Linear Check
Generated by Claude Code
Summary by cubic
Adds the design's field format rules to the Google Drive, SharePoint, OneDrive, and Notion config models, so invalid values now fail with the design's message as a form error on the field instead of during a capability check. The plan endpoint returns the rules as form errors.
- A Notion page URL saved in Root Page ID is converted to the page ID it holds; the connector and checks read the ID.
- The URL parser and the SharePoint site URL rule moved into
notion/config.pyandsharepoint/config.py, and OneDrive's email parsing reuses one helper. - The checks no longer test these formats; a stored config that breaks a rule still indexes as before.
- Slack and Outlook get no field rule: Slack's goes on the server and depends on a second field, and the design gives Outlook none.
Summary by CodeRabbit
- Bug Fixes
- Improved connector configuration validation for Google Drive, OneDrive, SharePoint, and Notion.
- Google Drive now clearly reports when no My Drive email is provided.
- OneDrive now validates configured email addresses and provides guidance for invalid entries.
- SharePoint now validates HTTPS site URLs and required site paths before connection checks.
- Notion now accepts supported page URLs or IDs and normalizes valid values consistently.
- Tests
- Expanded coverage for valid and invalid connector settings and user-facing error messages.