Skip to content

fix: 5 bugs found during integration testing#8

Merged
MauricioPerera merged 1 commit into
mainfrom
fix/five-bugs-from-testing
May 2, 2026
Merged

fix: 5 bugs found during integration testing#8
MauricioPerera merged 1 commit into
mainfrom
fix/five-bugs-from-testing

Conversation

@MauricioPerera
Copy link
Copy Markdown
Owner

Summary

Test plan

  • 264/264 existing tests pass
  • 12/12 new fix verification tests pass (all 5 fixes confirmed)
  • Build succeeds with tsup

Closes #1, #2, #3, #4, #5

🤖 Generated with Claude Code

- auth: await assignRole/removeRole so the operation completes before
  returning, fixing empty stdout on role assign/remove (#1)
- index: pass { type: 'sorted' } instead of { sorted: true } to
  js-doc-store createIndex, fixing --sorted flag being ignored (#2)
- vec import: accept { exported, records } wrapper object from vec
  export, not just bare arrays (#3)
- vec store-batch: read metadata from rec["metadata"] (with fallback
  to rec["meta"]) so JSONL metadata is preserved (#4)
- aggregate $unwind: strip leading $ from field name before passing
  to js-doc-store unwind(), fixing arrays not being flattened (#5)

Closes #1, #2, #3, #4, #5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MauricioPerera MauricioPerera merged commit c435d1a into main May 2, 2026
1 check failed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances database and vector command handlers by ensuring asynchronous role operations are awaited, refining the $unwind aggregation stage to handle leading $ prefixes, and updating index creation to specify types. It also improves batch operations by supporting a metadata field and allowing wrapped record arrays in imports. Feedback highlights the need to apply similar await fixes to the logout sub-command and suggests extending the $unwind logic to handle object-based path definitions.

Comment thread src/commands/db/auth.ts
Comment on lines +161 to +162
if (op === "assign") await auth.assignRole(targetUser, role);
else if (op === "remove") await auth.removeRole(targetUser, role);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Adding await here is correct as these operations are asynchronous and must complete before the handler returns to ensure the response is accurate and errors are caught.

Note that the same issue appears to exist in logoutSub (lines 136 and 138 in the full file), where auth.logoutAll() and auth.logout() are called without await. You should consider applying the same fix there to ensure consistent behavior and proper error handling during logout.

Comment thread src/commands/db/crud.ts
Comment on lines +253 to +257
case "$unwind": {
const unwindField = typeof arg === "string" && arg.startsWith("$") ? arg.slice(1) : arg;
pipe = pipe.unwind(unwindField as string);
break;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The fix for $unwind correctly handles the string shorthand by stripping the leading $. However, if the underlying library supports the object form of $unwind (e.g., {$unwind: { path: '$field', preserveNullAndEmptyArrays: true }}), this implementation will pass the object directly to pipe.unwind() with a string cast, and the leading $ inside the path property will remain.

If the object form is supported, you should also strip the $ from the path property within the object, similar to how it's handled in the $group stage (lines 214 and 233).

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.

auth: role assign no awaita operación y verify retorna roles obsoletos del JWT

1 participant