Skip to content

fix(connectors): correct SourceInfo fields in OneDrive connector (#9004) - #9585

Closed
mrveiss wants to merge 1 commit into
Dev_new_guifrom
fix/onedrive-source-info-clean
Closed

mrveiss wants to merge 1 commit into
Dev_new_guifrom
fix/onedrive-source-info-clean

Conversation

@mrveiss

@mrveiss mrveiss commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Thinking Path

Fixed a field mapping bug in the OneDrive connector where SourceInfo was being instantiated with incorrect field names. The connector was trying to use a description field that doesn't exist in the SourceInfo dataclass, causing TypeErrors at runtime when listing files.

The SourceInfo dataclass requires: source_id, name, path, content_type, size_bytes, last_modified, and optional metadata. The old code was passing description instead of the required path, content_type, and size_bytes fields.

What Changed

  • Updated _file_to_source_info() method in OneDrive connector to use the correct required fields
  • Added path extraction logic to parse Microsoft Graph API's path format (e.g., "/drive/root:/Documents" → "/Documents")
  • Added _get_content_type() helper method to map file extensions to proper MIME types
  • Updated test test_file_to_source_info_basic to verify the correct fields and include proper path data
  • Updated metadata fields to include drive_id and site_id

Verification

Verified the fix resolves the SourceInfo field mismatch:

# Check SourceInfo dataclass definition
grep -A 12 "class SourceInfo" autobot-backend/knowledge/connectors/models.py
# Shows required fields: source_id, name, path, content_type, size_bytes, last_modified

# Run OneDrive connector tests
pytest autobot-backend/knowledge/connectors/onedrive_test.py::TestOneDriveConnector::test_file_to_source_info_basic -v
# Test passes and verifies correct fields are populated

Model Used

Claude Sonnet 4.5

Related Issues

🤖 Generated with Claude Code

- Fix _file_to_source_info to use required SourceInfo fields (path, content_type, size_bytes) instead of deprecated description field
- Add _get_content_type helper to map file extensions to MIME types
- Update test to check correct SourceInfo fields with parentReference data
- All 16 tests now pass

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

@mrveiss mrveiss closed this Jun 5, 2026
@mrveiss

mrveiss commented Jun 5, 2026

Copy link
Copy Markdown
Owner Author

Closing due to CI failures (SAST, validation, frontend-tests, security-tests, startup-import-smoke). Part of PR limit enforcement (MVA-3660).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant