fix: support big csv files on langflow-less ingestion#1966
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The _purge_modules() list was missing "config.config_manager", so the ConfigManager singleton retained its cached _config from a previous test. Subsequent calls to get_openrag_config() returned the old config where disable_ingest_with_langflow=False, causing the router to use the Langflow path even though DISABLE_INGEST_WITH_LANGFLOW=true was set in the environment. Adding config.config_manager to the purge list forces a fresh load on the next import, picking up the correct env-var values.
DocumentFileProcessor ignores Docling's binary_hash field and computes document_id = hash_id(file_path) from the actual file content. The test was asserting against the literal mock value "sha-csv-integration-123" which never appears in the indexed documents, giving 0 hits and a false failure. Now the test derives expected_document_id via hash_id(csv_path) to match what the production code actually indexes.
|
@coderabbitai please create a PR against this fixing the errors that caused the integration test failures |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="langflow-ai/openrag"
pr="1966"
echo "== PR checks =="
gh pr checks "$pr" --repo "$repo" || true
echo
echo "== PR view (head/base, changed files summary) =="
gh pr view "$pr" --repo "$repo" --json number,title,headRefName,baseRefName,author,changedFiles,files,statusCheckRollup \
--jq '{
number,
title,
headRefName,
baseRefName,
author: .author.login,
changedFiles,
files: [.files[].path],
checks: [.statusCheckRollup[]? | {
name: (.name // .context // "unknown"),
status: .status,
conclusion: .conclusion,
detailsUrl: .detailsUrl
}]
}'
echo
echo "== Locate candidate files =="
fd -a 'document_processing.py|processors.py|test_document_processing_resplit.py|conftest.py|integration' . || true
echo
echo "== AST outline: src/utils/document_processing.py =="
ast-grep outline src/utils/document_processing.py --view expanded || true
echo
echo "== AST outline: src/models/processors.py =="
ast-grep outline src/models/processors.py --view expanded || true
echo
echo "== Relevant slices: src/utils/document_processing.py =="
sed -n '1,260p' src/utils/document_processing.py || true
echo
echo "== Relevant slices: src/models/processors.py =="
sed -n '1,420p' src/models/processors.py || true
echo
echo "== New/related tests =="
sed -n '1,260p' tests/unit/test_document_processing_resplit.py || true
echo
echo "== Search for split_chunks_by_max_tokens usages =="
rg -n -C2 '\bsplit_chunks_by_max_tokens\s*\(' src tests || true
echo
echo "== Search for integration tests mentioning document processing / ingestion =="
rg -n -C2 --iglob '*integration*' 'document_processing|process_document_standard|extract_relevant|split_chunks_by_max_tokens|embedding' tests || trueLength of output: 38801 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="langflow-ai/openrag"
run_id="28472586766"
job_id="84388865447"
echo "== Failed job metadata =="
gh api "repos/$repo/actions/jobs/$job_id" | jq '{name, status, conclusion, started_at, completed_at, html_url, steps: [.steps[] | {name, status, conclusion, number}]}'
echo
echo "== Failed job annotations =="
gh api "repos/$repo/check-runs/$job_id/annotations" || true
echo
echo "== Attempt to fetch run/job logs =="
tmpdir="$(mktemp -d)"
if gh run view "$run_id" --repo "$repo" --log > "$tmpdir/run.log" 2>/dev/null; then
echo "-- First 250 lines of run log --"
sed -n '1,250p' "$tmpdir/run.log"
else
echo "gh run view --log unavailable; trying gh api for logs URL"
logs_url=$(gh api "repos/$repo/actions/jobs/$job_id" --jq '.logs_url' || true)
echo "logs_url=${logs_url:-<none>}"
fi
echo
echo "== Integration test file outline =="
ast-grep outline tests/integration/core/test_non_langflow_ingestion.py --view expanded || true
echo
echo "== Integration test file contents =="
sed -n '1,260p' tests/integration/core/test_non_langflow_ingestion.py || true
echo
echo "== PR diff for changed files =="
gh pr diff 1966 --repo "$repo" -- src/models/processors.py src/utils/document_processing.py tests/integration/core/test_non_langflow_ingestion.py tests/unit/test_document_processing_resplit.py | sed -n '1,320p'Length of output: 37715 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="langflow-ai/openrag"
run_id="28472586766"
tmpdir="$(mktemp -d)"
logfile="$tmpdir/run.log"
echo "== Download full run log =="
gh run view "$run_id" --repo "$repo" --log > "$logfile"
echo
echo "== Pytest failure summary from log =="
rg -n -C4 'FAILED|FAILURES|ERROR|AssertionError|E +assert|traceback|short test summary info|test_non_langflow_csv_ingestion_with_splitting' "$logfile" || true
echo
echo "== Tail of run log =="
tail -n 220 "$logfile" || true
echo
echo "== Search for upload_ingest and document file processor path =="
rg -n -C3 '/router/upload_ingest|class DocumentFileProcessor|process_item\(|process_document_standard\(' src tests || true
echo
echo "== Focused slices around DocumentFileProcessor and upload flow =="
sed -n '460,760p' src/models/processors.py || true
echo
echo "== Git refs for current PR branch vs base =="
git rev-parse HEAD
git branch --show-current || true
git remote -v | head
echo
echo "== Focused git diff for relevant files =="
git diff -- src/models/processors.py src/utils/document_processing.py tests/integration/core/test_non_langflow_ingestion.py tests/unit/test_document_processing_resplit.py | sed -n '1,360p' || trueLength of output: 147660
What’s failing in
Notably:
So the actionable fix is around lifespan/startup initialization and RBAC expectations/permissions in the migration test, not the new document chunking logic.
Failed to handle agent chat message. Please try again. |
This pull request enhances the document chunking and embedding workflow to ensure that text chunks sent for embedding are properly aligned with their embeddings, particularly by splitting oversized chunks before batching. It also improves the robustness of table extraction and adds comprehensive unit tests for the new chunk-splitting logic and edge cases in document processing.
Document chunking and embedding alignment:
split_chunks_by_max_tokensinsrc/utils/document_processing.pyto pre-split any chunk whose token count exceeds a model-specific limit, ensuring that each chunk aligns 1-to-1 with its embedding. This function uses the appropriate tokenizer based on the embedding model.split_chunks_by_max_tokensinto the document processing pipeline insrc/models/processors.py, so that chunks are split before batching for embeddings, preventing misalignment between chunks and their embeddings. [1] [2]Robustness improvements in table extraction:
extract_relevantinsrc/utils/document_processing.pyto safely handle cases where table data is missing (None), preventing errors during extraction.Testing:
tests/unit/test_document_processing_resplit.pyforsplit_chunks_by_max_tokens, covering both under-limit and over-limit scenarios, and for handling tables with missing data inextract_relevant.Refactoring and cleanup:
texts) inprocess_document_standardafter refactoring the chunk splitting logic.