Skip to content

Experimental: Add get document tasks method#2156

Open
Strift wants to merge 1 commit intomainfrom
feat/add-get-tasks-documents
Open

Experimental: Add get document tasks method#2156
Strift wants to merge 1 commit intomainfrom
feat/add-get-tasks-documents

Conversation

@Strift
Copy link
Copy Markdown
Collaborator

@Strift Strift commented Mar 25, 2026

Pull Request

Related issue

Fixes #2151

What does this PR do?

  • Add code samples
  • Add getTaskDocumentsStream() method
  • Add tests

AI disclosure

Cursor with gpt-5.4-medium and codex-5.3-medium

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features
    • Added support for streaming task documents, enabling more efficient retrieval and processing of large document collections.

@Strift Strift added the enhancement New feature or request label Mar 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

A new streaming method is added to retrieve task documents from the GET /tasks/{uid}/documents endpoint. The HTTP client gains a public getStream() method, which is leveraged by a new TaskClient.getTaskDocumentsStream() method. Tests validate the functionality with success, error, and URL construction scenarios, and a code example is provided.

Changes

Cohort / File(s) Summary
HTTP Streaming Support
src/http-requests.ts
Added public getStream(options: RequestOptions) method that returns a Promise<ReadableStream<Uint8Array>> by delegating to the private #requestStream() method.
Task Documents Streaming
src/task.ts
Added public getTaskDocumentsStream(uid, extraRequestInit?) method to fetch task documents via streaming; refactored abort callback in waitForTask from arrow to block body.
Test Coverage
tests/task.test.ts
Added experimental feature flag for getTaskDocumentsRoute and three test cases: success scenario parsing newline-delimited JSON documents, error handling for nonexistent tasks, and URL path validation with malformed hosts.
Documentation Sample
.code-samples.meilisearch.yaml
Added code sample get_task_documents_1 demonstrating streaming task document retrieval via client.tasks.getTaskDocumentsStream(1).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A stream of documents flows so free,
Tasks retrieve their data with streaming glee,
From HTTP requests both new and bright,
The rabbit hops forward—a delightful sight! 📄✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Experimental: Add get document tasks method' accurately describes the primary change: adding a new method to retrieve task documents via streaming.
Linked Issues check ✅ Passed All three coding objectives from issue #2151 are met: the getTaskDocumentsStream method is added, comprehensive tests are included, and the code sample is provided in the YAML file.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue #2151. The modifications to abort callback formatting in waitForTask appear to be a minor refactoring aligned with coding standards, not unrelated scope creep.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 feat/add-get-tasks-documents

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.96%. Comparing base (4621dd3) to head (40f5012).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2156      +/-   ##
==========================================
+ Coverage   97.95%   97.96%   +0.01%     
==========================================
  Files          15       15              
  Lines         635      640       +5     
  Branches      105      104       -1     
==========================================
+ Hits          622      627       +5     
  Misses         12       12              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/task.test.ts (1)

34-36: Consider cleaning up experimental feature state.

The getTaskDocumentsRoute experimental feature is enabled in beforeEach but not reset in the file's afterAll hook (lines 25-27). While tests/experimental-features.test.ts has its own cleanup, test file execution order isn't guaranteed, which could lead to flaky behavior if tests depend on feature state.

Consider adding cleanup to the existing afterAll:

♻️ Suggested change
 afterAll(() => {
-  return clearAllIndexes(config);
+  const client = await getClient("Master");
+  await client.updateExperimentalFeatures({
+    getTaskDocumentsRoute: false,
+  });
+  return clearAllIndexes(config);
 });

Or make afterAll async:

-afterAll(() => {
-  return clearAllIndexes(config);
+afterAll(async () => {
+  const client = await getClient("Master");
+  await client.updateExperimentalFeatures({
+    getTaskDocumentsRoute: false,
+  });
+  await clearAllIndexes(config);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/task.test.ts` around lines 34 - 36, The tests enable the experimental
flag getTaskDocumentsRoute in beforeEach but never reset it, which can leak
state across test files; update the existing afterAll to asynchronously call
client.updateExperimentalFeatures to disable or reset getTaskDocumentsRoute
(e.g., set getTaskDocumentsRoute: false or clear experimental flags) and ensure
afterAll is marked async if needed so the cleanup call (using
updateExperimentalFeatures) completes before process exit; reference the
beforeEach that sets getTaskDocumentsRoute and the afterAll cleanup to locate
where to add the reset.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/task.test.ts`:
- Around line 34-36: The tests enable the experimental flag
getTaskDocumentsRoute in beforeEach but never reset it, which can leak state
across test files; update the existing afterAll to asynchronously call
client.updateExperimentalFeatures to disable or reset getTaskDocumentsRoute
(e.g., set getTaskDocumentsRoute: false or clear experimental flags) and ensure
afterAll is marked async if needed so the cleanup call (using
updateExperimentalFeatures) completes before process exit; reference the
beforeEach that sets getTaskDocumentsRoute and the afterAll cleanup to locate
where to add the reset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6185f40d-5697-41db-a29f-9f2b929c950c

📥 Commits

Reviewing files that changed from the base of the PR and between 4621dd3 and 40f5012.

📒 Files selected for processing (4)
  • .code-samples.meilisearch.yaml
  • src/http-requests.ts
  • src/task.ts
  • tests/task.test.ts

@Strift Strift requested a review from flevi29 March 30, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Meilisearch v1.13.0] Add method to get tasks documents

1 participant