Skip to content

fix(moss-md-indexer): upload through @moss-js/moss instead of the legacy REST SDK - #567

Closed
juangl wants to merge 1 commit into
mainfrom
fix/md-indexer-current-sdk
Closed

juangl wants to merge 1 commit into
mainfrom
fix/md-indexer-current-sdk

Conversation

@juangl

@juangl juangl commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Pull Request Checklist

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable). CHANGELOG entry added; the README has no SDK-specific instructions to change.
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works. The package has no test runner; see "How I tested" below.
  • New and existing unit tests pass locally with my changes.

Description

@moss-tools/md-indexer uploads through @inferedge-rest/moss, a pre-1.0 SDK that calls moss-control's legacy /manage deleteIndex + createIndex. That blocks the moss-control release:

  • usemoss/infra-moss-tf#317 (MOS-654) retires the /manage write actions (they answer 410). Its precondition is no write traffic left on /manage.
  • In the last 90 days the only steady /manage write caller is the moss_vitepress Vercel project (root packages/vitepress-plugin-moss/demo-site). On every push to main its build runs vitepress-plugin-moss → md-indexer 1.0.0-beta.3 → deleteIndex then createIndex on index filter, twice per build. Once release: Moss iOS SDK v0.6.0 #317 ships, the delete would still succeed and the create would fail, leaving the docs site with no search index.
  • Indexes built that way also carry no model artifact identity, so current SDKs refuse text queries on them.

This PR swaps the client for MossClient from @moss-js/moss (1.21.0, the current JS SDK; @moss-dev/moss is the older name, still at 1.7.1). It builds indexes in moss-index-manager (service.usemoss.dev/index) and never calls moss-control.

Behaviour is otherwise unchanged: delete the index if present, then create it with the configured model (modelId). The public API (uploadDocuments, createIndex, sync, buildJsonDocs, types) is the same. The client is now closed after use.

This covers the same SDK migration as #528, kept to the minimum needed to unblock the moss-control release. #528 also switches to a non-destructive upsert. That's worth doing as a follow-up, but as written it would throw on the live filter index (it was built by the old SDK, so it has no model version) instead of rebuilding it. Thanks to @PredictiveManish for flagging the legacy dependency.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How I tested

  • pnpm build (tsc) passes; dist/ has no reference to @inferedge-rest/moss.
  • Ran the built uploader with @moss-js/moss mocked (Node 24, node:test):
    • It calls delete → create, with { modelId }, then closes the client.
    • A missing index isn't an error.
    • Other delete errors only warn.
    • A create failure is wrapped as Moss Upload Failed: … and the client is still closed.
    • An empty document list makes no calls.
  • Loaded the real @moss-js/moss native module under Node 24.22.1 and opened and closed a client.
  • Not run against a live project. The first real run will be the moss_vitepress build after step 3 below.

Rollout (needed for the docs site to pick this up)

  1. Merge, then run Publish moss-md-indexer (workflow_dispatch) to publish 1.0.0-beta.4. Its last two runs in April failed. The logs have expired, but they most likely tried to republish 1.0.0-beta.3, and the version bump avoids that.
  2. Follow-up PR: update packages/vitepress-plugin-moss/pnpm-lock.yaml to md-indexer 1.0.0-beta.4. The demo site installs the plugin's dependencies from that lockfile, so ^1.0.0-beta.3 alone keeps resolving beta.3.
  3. Check the next moss_vitepress build log, and confirm moss-control's CloudWatch shows no /manage writes from that project.

package-lock.json in this package was already stale. Regenerating it churns about 1,900 lines, so I left it alone; publishing uses pnpm-lock.yaml.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Compatibility
    • Updated Markdown index uploads to use the current Moss SDK.
    • Index creation now passes the selected model to the indexing service, supporting text queries with current SDKs.
    • Legacy SDK /manage write actions are being retired; use current SDKs to manage indexes.
  • Bug Fixes
    • Improved handling of missing-index errors and client cleanup during index operations.

…gacy REST SDK

md-indexer used @inferedge-rest/moss, which calls moss-control's legacy
/manage createIndex/deleteIndex. moss-control is retiring the /manage write
actions (usemoss/infra-moss-tf#317), and indexes built that way carry no model
artifact identity, so current SDKs refuse text queries on them.

The moss_vitepress demo site rebuilds its index through this package on every
push to main, and is the only steady /manage write caller left.

Swap the client for MossClient from @moss-dev/moss, which builds indexes in
moss-index-manager. Behaviour is unchanged: delete the index if present, then
create it with the configured model. The client is now closed after use.
Bumps the package to 1.0.0-beta.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 67835bde-7ff2-4d3a-89db-1761e962daf8
📥 Commits

Reviewing files that changed from the base of the PR and between 2e638ec and 9f4a5f0.

⛔ Files ignored due to path filters: 1
  • packages/moss-md-indexer/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 3
  • packages/moss-md-indexer/CHANGELOG.md
  • packages/moss-md-indexer/package.json
  • packages/moss-md-indexer/src/uploader.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The indexer package advances to 1.0.0-beta.4 and replaces @inferedge-rest/moss with @moss-dev/moss. The uploader uses MossClient, passes the model as modelId, and closes clients it creates.

Changes: Moss SDK migration

Layer / File(s) Summary
Update uploader SDK integration
packages/moss-md-indexer/package.json, packages/moss-md-indexer/src/uploader.ts, packages/moss-md-indexer/CHANGELOG.md
The package version advances to 1.0.0-beta.4 and its dependency changes to @moss-dev/moss. The uploader uses MossClient, passes the model name as modelId, handles not-found messages without case sensitivity, and closes clients it creates. The changelog describes the SDK change and index-service workflow.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9f4a5

The SDK migration has no identified merge-blocking issue. The first live index build remains a rollout check.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: replacing the legacy REST SDK with @moss-dev/moss for uploads.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/moss-md-indexer/package.json">

<violation number="1" location="packages/moss-md-indexer/package.json:26">
P2: This manifest change leaves the tracked npm lockfile on beta.3 and `@inferedge-rest/moss`, so `npm ci` cannot reproduce the new dependency set. Regenerate or remove `packages/moss-md-indexer/package-lock.json` to keep the repository’s install metadata consistent.</violation>

<violation number="2" location="packages/moss-md-indexer/package.json:26">
P2: `@moss-dev/moss@1.7.1` requires Node 20.4+, but this package still documents Node 18+ and does not declare an engine requirement. Update the runtime documentation and package `engines`, or choose an SDK compatible with Node 18.</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Turn on auto-fix | Re-trigger cubic

},
"dependencies": {
"@inferedge-rest/moss": ">=1.0.0-beta.3",
"@moss-dev/moss": "^1.7.1",

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.

P2: This manifest change leaves the tracked npm lockfile on beta.3 and @inferedge-rest/moss, so npm ci cannot reproduce the new dependency set. Regenerate or remove packages/moss-md-indexer/package-lock.json to keep the repository’s install metadata consistent.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/moss-md-indexer/package.json, line 26:

<comment>This manifest change leaves the tracked npm lockfile on beta.3 and `@inferedge-rest/moss`, so `npm ci` cannot reproduce the new dependency set. Regenerate or remove `packages/moss-md-indexer/package-lock.json` to keep the repository’s install metadata consistent.</comment>

<file context>
@@ -23,7 +23,7 @@
   },
   "dependencies": {
-    "@inferedge-rest/moss": ">=1.0.0-beta.3",
+    "@moss-dev/moss": "^1.7.1",
     "cheerio": "^1.0.0",
     "dotenv": "^16.4.5",
</file context>

},
"dependencies": {
"@inferedge-rest/moss": ">=1.0.0-beta.3",
"@moss-dev/moss": "^1.7.1",

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.

P2: @moss-dev/moss@1.7.1 requires Node 20.4+, but this package still documents Node 18+ and does not declare an engine requirement. Update the runtime documentation and package engines, or choose an SDK compatible with Node 18.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/moss-md-indexer/package.json, line 26:

<comment>`@moss-dev/moss@1.7.1` requires Node 20.4+, but this package still documents Node 18+ and does not declare an engine requirement. Update the runtime documentation and package `engines`, or choose an SDK compatible with Node 18.</comment>

<file context>
@@ -23,7 +23,7 @@
   },
   "dependencies": {
-    "@inferedge-rest/moss": ">=1.0.0-beta.3",
+    "@moss-dev/moss": "^1.7.1",
     "cheerio": "^1.0.0",
     "dotenv": "^16.4.5",
</file context>

@juangl juangl closed this Oct 23, 2026
@juangl juangl changed the title fix(moss-md-indexer): upload through @moss-dev/moss instead of the legacy REST SDK fix(moss-md-indexer): upload through @moss-js/moss instead of the legacy REST SDK Oct 23, 2026
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