Skip to content

fix: accept legacy positional task executor index - #16147

Merged
wangq8 merged 3 commits into
infiniflow:0.27.xfrom
helloxjade:fix-task-executor-legacy-index
Oct 21, 2026
Merged

wangq8 merged 3 commits into
infiniflow:0.27.xfrom
helloxjade:fix-task-executor-legacy-index

Conversation

@helloxjade

@helloxjade helloxjade commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Before the task executor refactor in #15154, the worker index was read from sys.argv[1], and the in-repo launchers passed it positionally. The refactor migrated the current in-repo launchers to -i/--index, but external deployment configurations copied from older RAGFlow versions may still use the former positional interface.

In the affected deployment environment, this caused argparse to exit with unrecognized arguments and the worker to restart in a loop.

This PR preserves compatibility with those external deployment configurations while keeping the current -i/--index behavior. When both forms are provided with conflicting values, the positional value continues to take precedence and a warning is emitted.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

Testing

  • Added/updated tests
  • Verified with:
    • .venv/bin/pytest -q test/unit_test/rag/svr/test_task_executor_cli.py — 4 passed
    • .venv/bin/ruff check rag/svr/task_executor_cli.py test/unit_test/rag/svr/test_task_executor_cli.py
    • .venv/bin/python -m py_compile rag/svr/task_executor.py rag/svr/task_executor_cli.py

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. labels Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 27500b37-d20d-45c6-ad23-d4d60ee69c2a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3bb36283-aaf3-43b0-88f1-89553ad8ac14

📥 Commits

Reviewing files that changed from the base of the PR and between 1559125 and c40dbde.

📒 Files selected for processing (3)
  • rag/svr/task_executor.py
  • rag/svr/task_executor_cli.py
  • test/unit_test/rag/svr/test_task_executor_cli.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The task executor now delegates CLI parsing and index resolution to rag.svr.task_executor_cli. Positional indexes remain supported and take precedence over -i/--index. Conflicts generate warnings, and legacy usage generates an info log.

Changes: CLI Compatibility

Layer / File(s) Summary
CLI index contract
rag/svr/task_executor_cli.py
Adds reusable argument parsing, positional-index precedence, and conflict or legacy-use logging.
Task executor wiring and validation
rag/svr/task_executor.py, test/unit_test/rag/svr/test_task_executor_cli.py
Uses the new CLI helpers and tests named, positional, matching, and conflicting indexes.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c40db

Task executors can again start with legacy positional worker indexes while retaining the named index option. Conflicts are visible in logs, and the compatibility behavior is covered by tests.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly describes the main change: restoring support for a legacy positional task executor index.
Description check ✅ Passed The description clearly explains the problem, compatibility behavior, conflict handling, change type, and verification. It does not use the template's exact "### Summary" heading, but it provides the …

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

A rabbit parses flags in the moonlit glow
Positional indexes choose where to go
Conflicts raise warnings, clear and bright
Matching values keep the path right
Tests hop softly through each case
The executor starts in its proper place

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

@helloxjade

Copy link
Copy Markdown
Contributor Author

Error logs before fix:

/ragflow/.venv/lib/python3.13/site-packages/graspologic/match/wrappers.py:227: SyntaxWarning: invalid escape sequence '\s'
  .. math:: f(P) = - \sum_{k=1}^K \|A^{(k)} - PB^{(k)}P^T\|_F^2 - \sum_{k=1}^K \|(AB)^{(k)}P^T - P(BA)^{(k)}\|_F^2 + trace(SP^T)
/ragflow/.venv/lib/python3.13/site-packages/graspologic/pipeline/embed/adjacency_spectral_embedding.py:123: SyntaxWarning: invalid escape sequence '\S'
  .. math:: A = U \Sigma V^T
/ragflow/.venv/lib/python3.13/site-packages/graspologic/pipeline/embed/laplacian_spectral_embedding.py:127: SyntaxWarning: invalid escape sequence '\S'
  .. math:: A = U \Sigma V^T
usage: task_executor.py [-h] [-i INDEX] [-t TYPE]
task_executor.py: error: unrecognized arguments: worker_positional_arg
/ragflow/.venv/lib/python3.13/site-packages/xgboost/compat.py:105: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
10:24:39 - LiteLLM:WARNING: get_model_cost_map.py:174 - LiteLLM: Failed to fetch remote model cost map from https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json: The read operation timed out. Falling back to local backup.
WARNING:LiteLLM:LiteLLM: Failed to fetch remote model cost map from https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json: The read operation timed out. Falling back to local backup.
/ragflow/.venv/lib/python3.13/site-packages/scholarly/_scholarly.py:312: SyntaxWarning: invalid escape sequence '\d'
  m = re.search("cites=[\d+,]*", object["citedby_url"])
/ragflow/.venv/lib/python3.13/site-packages/graspologic/align/seedless_procrustes.py:125: SyntaxWarning: invalid escape sequence '\i'
  are represented with matrices :math:`X \in M_{n, d}` and
/ragflow/.venv/lib/python3.13/site-packages/hyppo/kgof/kernel.py:90: SyntaxWarning: invalid escape sequence '\s'
  Compute \sum_{i=1}^d \frac{\partial^2 k(X, Y)}{\partial x_i \partial y_i}
/ragflow/.venv/lib/python3.13/site-packages/hyppo/kgof/kernel.py:129: SyntaxWarning: invalid escape sequence '\s'
  Compute \sum_{i=1}^d \frac{\partial^2 k(x, Y)}{\partial x_i \partial y_i}
/ragflow/.venv/lib/python3.13/site-packages/hyppo/kgof/kernel.py:264: SyntaxWarning: invalid escape sequence '\s'
  Compute \sum_{i=1}^d \frac{\partial^2 k(X, Y)}{\partial x_i \partial y_i}

Before this fix, the deployment launcher passes worker index as a positional argument without the -i flag. The original task_executor.py only accepts index via -i/--index, which leads to the unrecognized arguments error and makes the worker crash and restart repeatedly.

This PR keeps the original -i/--index logic intact, and adds backward compatibility to support positional worker index as a fallback, which resolves the startup failure.

@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 `@rag/svr/task_executor.py`:
- Around line 1913-1920: The backward compatibility path for legacy_index in the
argument parsing section lacks logging, making it difficult for operators to
debug which input method was used. After the TE_IDX assignment on line 1920, add
an explicit log statement that checks if args.legacy_index is not None and logs
that the legacy positional index path is being used. Additionally, if both
args.legacy_index and args.index are provided (non-None), emit a warning log to
indicate that legacy_index is taking precedence over the new --index argument.
This ensures visibility into which compatibility path is being selected during
startup.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 707032e1-c407-43b1-a977-fc6d65c95217

📥 Commits

Reviewing files that changed from the base of the PR and between 9302233 and ba16a22.

📒 Files selected for processing (1)
  • rag/svr/task_executor.py

Comment thread rag/svr/task_executor.py Resolved
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@xugangqiang

xugangqiang commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks for the fix. Reviewed the change and have a few findings:

1. The "legacy positional index" has no in-repo caller (scope/intent)
All in-repo launchers pass the index via -i:

  • docker/entrypoint.sh:230 → task_executor.py -i "${host_id}_${consumer_id}" -t "common"
  • docker/entrypoint-go.sh:230 → same
  • docker/launch_backend_service.sh:101 → task_cmd=("$PY" "rag/svr/task_executor.py" "-i" "$task_id")

None passes a positional index, so the failing path only exists in an out-of-repo launcher. The shim is harmless and solves your real deployment crash, but it is a compatibility-only branch with no repo contract. Please note this in the PR description so future maintainers don't assume an in-repo caller exists.

2. Silent precedence conflict when both -i and the positional arg are given
TE_IDX = args.legacy_index or args.index makes the positional value win whenever both are present, with no signal. If a launcher ever passes -i 5 and a positional 3, the worker silently uses 3. Consider adding a warning when args.legacy_index is not None and args.index not in ("0", args.legacy_index) so misconfiguration is visible (the original CodeRabbit suggestion for a conflict warning was not addressed — only the basic info log was added).

3. No test coverage for the new CLI behavior
The PR only used py_compile. There is no test asserting that (a) a positional index is accepted, (b) -i still works, and (c) the two coexist as expected. test/unit_test/rag/svr/task_executor_refactor/* does not touch main()'s argparse. A small local test driving argparse with sys.argv would prevent regressions without needing any external service.

Overall the fix is correct and low-risk for in-repo launchers; addressing #2 (conflict warning) and #3 (test) before merge would make it a clean net gain.

Please let me know your thoughts.

@helloxjade

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. I addressed #2 and #3 in c40dbde:

  • Added a warning when -i/--index conflicts with the positional index, while preserving positional precedence.
  • Added focused tests covering positional-only, -i-only, matching values, and conflicting values.

For #1, I updated the PR description to clarify the compatibility scope. Before the task executor refactor in #15154, the in-repo launchers passed the worker index positionally and task_executor.py read it from sys.argv[1]. Current in-repo launchers use -i, while external deployment configurations copied from older versions may still use the former positional interface.

The focused test suite passes with 4 tests. Could you please take another look?

@xugangqiang xugangqiang added the ci Continue Integration label Sep 16, 2026
@xugangqiang

Copy link
Copy Markdown
Collaborator

LGTM

@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.11%. Comparing base (1638145) to head (9b42b97).

Additional details and impacted files
@@           Coverage Diff           @@
##           0.27.x   #16147   +/-   ##
=======================================
  Coverage   38.11%   38.11%           
=======================================
  Files          54       54           
  Lines       15533    15533           
  Branches      125      125           
=======================================
  Hits         5920     5920           
  Misses       9585     9585           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@helloxjade

Copy link
Copy Markdown
Contributor Author

LGTM

Thanks for the LGTM. Since the review, #20289 removed rag/svr/task_executor.py and task execution moved to the Go ingestor. This PR now has a delete/modify conflict. Should this fix be adapted to the Go path, or is it superseded?

@xugangqiang

Copy link
Copy Markdown
Collaborator

please try to change the base: infiniflow:main (now) -> 0.27.x (python only). infiniflow:main(now) is golang only. Python version will contine to have ingestor.

@helloxjade
helloxjade changed the base branch from main to 0.27.x September 30, 2026 02:48
@xugangqiang

Copy link
Copy Markdown
Collaborator

@helloxjade please rebase and then I will review. Thank you.

@helloxjade
helloxjade force-pushed the fix-task-executor-legacy-index branch from c40dbde to 9b42b97 Compare October 20, 2026 15:39
@wangq8
wangq8 merged commit 41ba7dd into infiniflow:0.27.x Oct 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration 🌈 python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants