Skip to content

chore: fix main#1613

Merged
ricofurtado merged 7 commits into
mainfrom
fix-main-imports
May 15, 2026
Merged

chore: fix main#1613
ricofurtado merged 7 commits into
mainfrom
fix-main-imports

Conversation

@edwinjosechittilappilly

@edwinjosechittilappilly edwinjosechittilappilly commented May 14, 2026

Copy link
Copy Markdown
Collaborator

This pull request modernizes type hinting throughout the docling_service.py and langflow_file_service.py modules by adopting Python 3.10+ syntax (e.g., str | None instead of Optional[str], dict[str, Any] instead of Dict[str, Any]). It also updates enum usage to leverage StrEnum for better type safety and string handling, and improves error handling in Docling submission. These changes enhance code readability, maintainability, and take advantage of newer Python features.

Type hint modernization

  • Replaced legacy type hints such as Optional[str] and Dict[str, Any] with Python 3.10+ syntax (str | None, dict[str, Any]) across function signatures and class attributes in both src/services/docling_service.py and src/services/langflow_file_service.py. [1] [2] [3] [4] [5] [6]

Enum improvements

  • Changed DoclingTaskState from inheriting Enum to StrEnum for more robust string-based enum handling in src/services/docling_service.py. [1] [2]

Error handling

  • Improved exception chaining in submit_to_docling by using raise ... from e to preserve the original error context in src/services/langflow_file_service.py.

Summary by CodeRabbit

  • Refactor
    • Modernized type annotations across service modules for clearer, more consistent interfaces.
  • Bug Fixes
    • Improved error propagation in file submission flows by preserving original exception context.

Review Change Stack

Replace typing.Optional/Dict with PEP 604 union syntax and built-in dict annotations to modernize type hints (requires Python 3.10+). Update annotations in DoclingStatusSnapshot (detail/raw), DoclingService.__init__ and fetch_task_result. Clean up and reorder imports (platform moved up, removed unused typing names) for clarity.
Switch DoclingTaskState to StrEnum (imported from enum) so enum members are proper string enums. Also preserve the original error context in LangflowFileService by raising the upload exception with "from e" to keep exception chaining and traceback information.
@github-actions github-actions Bot added the backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) label May 14, 2026
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ff5dc8b-d5f7-47d1-9a36-9c72f8ad9ff7

📥 Commits

Reviewing files that changed from the base of the PR and between 5306760 and aa14716.

📒 Files selected for processing (1)
  • src/services/langflow_file_service.py

Walkthrough

Type annotations are modernized across two service modules: DoclingTaskState adopts StrEnum, optional and dictionary types use PEP 604 union syntax (T | None) and built-in generics (dict[...]) respectively, and error handling includes explicit exception chaining in submit_to_docling.

Changes

Type Annotation Modernization

Layer / File(s) Summary
Docling service type modernization
src/services/docling_service.py
Imports StrEnum; DoclingTaskState changes from str, Enum to StrEnum; DoclingStatusSnapshot fields switch from Optional[...] to `str
LangflowFileService method signatures
src/services/langflow_file_service.py
upload_user_file, submit_to_docling, and upload_and_ingest_file methods receive updated signatures with Optional[...] → `

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

refactor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'chore: fix main' is vague and does not clearly describe the specific changes being made to the codebase. Consider using a more descriptive title that reflects the primary changes, such as 'chore: modernize type hints to Python 3.10+ syntax' or 'chore: update type annotations and improve enum handling'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-main-imports

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the lgtm label May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Modernizes Python typing syntax in Docling/Langflow services, switches Docling task state enums to StrEnum, and improves Docling submission error chaining.

Changes:

  • Updated type hints to Python 3.10+ union/generic syntax (str | None, dict[str, Any])
  • Switched DoclingTaskState from Enum to StrEnum
  • Added exception chaining (raise ... from e) for Docling submission failures

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/services/langflow_file_service.py Updates function signatures to modern type hints; improves Docling submission exception chaining
src/services/docling_service.py Migrates enum to StrEnum and modernizes several type hints

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/services/langflow_file_service.py Outdated
from enum import Enum
import platform
from dataclasses import dataclass
from enum import StrEnum


class DoclingTaskState(str, Enum):
class DoclingTaskState(StrEnum):
extra={"error": str(e), "filename": filename},
)
raise Exception(f"Docling upload failed: {str(e)}")
raise Exception(f"Docling upload failed: {str(e)}") from e

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/services/langflow_file_service.py`:
- Around line 600-602: The call to submit_to_docling uses invalid keyword args
user_id and auth_header which that function does not accept; update the call at
the submit_to_docling invocation to match its actual signature by removing those
kwargs and passing the correct parameters (e.g., use the positional/keyword
names defined in submit_to_docling or pass only filename and content), or
alternatively update submit_to_docling to accept owner/jwt_token if that was
intended; reference submit_to_docling and the variables owner and jwt_token when
making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 149170f6-3c29-448c-b4e1-3c546398ed91

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2d4cf and 5306760.

📒 Files selected for processing (2)
  • src/services/docling_service.py
  • src/services/langflow_file_service.py

Comment thread src/services/langflow_file_service.py Outdated
Comment on lines +600 to +602
task_id = await self.submit_to_docling(
filename, content, user_id=owner, auth_header=jwt_token
)

@coderabbitai coderabbitai Bot May 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix mismatched keyword arguments in submit_to_docling call (Line 600).

submit_to_docling does not accept user_id/auth_header; this currently fails mypy and will raise TypeError at runtime.

Proposed fix
-        task_id = await self.submit_to_docling(
-            filename, content, user_id=owner, auth_header=jwt_token
-        )
+        task_id = await self.submit_to_docling(
+            filename, content, owner=owner, jwt_token=jwt_token
+        )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
task_id = await self.submit_to_docling(
filename, content, user_id=owner, auth_header=jwt_token
)
task_id = await self.submit_to_docling(
filename, content, owner=owner, jwt_token=jwt_token
)
🧰 Tools
🪛 GitHub Actions: Lint Backend / 0_Ruff and mypy on changed files.txt

[error] 600-600: mypy error: Unexpected keyword argument "user_id" for "submit_to_docling" of "LangflowFileService" [call-arg]


[error] 600-600: mypy error: Unexpected keyword argument "auth_header" for "submit_to_docling" of "LangflowFileService" [call-arg]

🪛 GitHub Actions: Lint Backend / Ruff and mypy on changed files

[error] 600-600: mypy: Unexpected keyword argument "user_id" for "submit_to_docling" of "LangflowFileService" [call-arg]


[error] 600-600: mypy: Unexpected keyword argument "auth_header" for "submit_to_docling" of "LangflowFileService" [call-arg]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/services/langflow_file_service.py` around lines 600 - 602, The call to
submit_to_docling uses invalid keyword args user_id and auth_header which that
function does not accept; update the call at the submit_to_docling invocation to
match its actual signature by removing those kwargs and passing the correct
parameters (e.g., use the positional/keyword names defined in submit_to_docling
or pass only filename and content), or alternatively update submit_to_docling to
accept owner/jwt_token if that was intended; reference submit_to_docling and the
variables owner and jwt_token when making the change.

✅ Addressed in commit 8cdcc34

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines 3 to 6
import platform
from dataclasses import dataclass
from enum import StrEnum
from pathlib import Path
@ricofurtado
ricofurtado merged commit e7fb324 into main May 15, 2026
17 of 19 checks passed
@github-actions
github-actions Bot deleted the fix-main-imports branch May 15, 2026 01:12
ricofurtado added a commit that referenced this pull request May 23, 2026
* fix imports

* ruff fix

* Use PEP 604 types and modernize imports

Replace typing.Optional/Dict with PEP 604 union syntax and built-in dict annotations to modernize type hints (requires Python 3.10+). Update annotations in DoclingStatusSnapshot (detail/raw), DoclingService.__init__ and fetch_task_result. Clean up and reorder imports (platform moved up, removed unused typing names) for clarity.

* Use StrEnum for DoclingTaskState; chain exception

Switch DoclingTaskState to StrEnum (imported from enum) so enum members are proper string enums. Also preserve the original error context in LangflowFileService by raising the upload exception with "from e" to keep exception chaining and traceback information.

* style: ruff format (auto)

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* style: ruff format (auto)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Rico Furtado <hfurtado@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) ignore-for-release lgtm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants