Skip to content

HCK-18349: reverse-engineer index defer_build and num_replica from the instance - #74

Merged
serhii-filonenko merged 2 commits into
developfrom
fix/re-index-with-options
Oct 29, 2026
Merged

serhii-filonenko merged 2 commits into
developfrom
fix/re-index-with-options

Conversation

@Sylvie-P

@Sylvie-P Sylvie-P commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Jira: HCK-18349

Problem

When we reverse-engineer from an instance, the index WITH options are lost. An index pushed with defer_build: true comes back without it.

The RE reads indexes from SELECT * FROM system:indexes, and this view has no WITH options at all (checked on a real instance, only state is there). REST /indexStatus has them: definition (with "defer_build":true), numReplica and hosts.

Change

In reverse_engineering/helpers/indexHelper.js, the instance RE now also calls /indexStatus and matches each index by bucket, scope, collection and name:

  • defer_build: true if the state is deferred or the definition contains "defer_build":true, else not set.
  • num_replica: from numReplica, only when > 0 (0 is the default).
  • withOptions is set only when one of these options is found, so an index without option stays as before (feature RE and apply-to-instance models unchanged).
  • nodes: not reverse-engineered on purpose. /indexStatus always reports hosts, even when no nodes were specified, so a round-trip would add nodes to every index.

If /indexStatus fails, the error is logged and RE continues: defer_build still comes from the state, num_replica stays empty.

Known limit

An index created deferred and then built keeps defer_build only if Couchbase keeps it in the definition. Not verified (no BUILD INDEX in the test).

Tests

  • npm test: 123 passed, 0 failed (new cases in test/reverse_engineering/indexes.test.js).
  • oxlint on touched files: no error.
  • Manual: round-trip on a single-node cluster (apply to instance, then RE into a new model). Expected: Defer build checked on deferred indexes, unchecked on others, Nbr of replicas and Nodes empty.

Made with Cursor

system:indexes returns no WITH options, so read them from REST /indexStatus:
- defer_build: true when the index state is deferred or its definition has defer_build
- num_replica: from numReplica, only when greater than 0
- nodes are not reverse-engineered, since hosts are always reported

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sylvie-P Sylvie-P changed the title RE: reverse-engineer index defer_build and num_replica from the instance HCK-18349: reverse-engineer index defer_build and num_replica from the instance Oct 28, 2026
An index without option was reverse-engineered with withOptions.defer_build false,
which broke the feature RE and apply-to-instance comparisons. A missing value
already shows the checkbox unchecked.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@serhii-filonenko
serhii-filonenko merged commit 8fa5b0c into develop Oct 29, 2026
1 check passed
@serhii-filonenko
serhii-filonenko deleted the fix/re-index-with-options branch October 29, 2026 11:13
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.

2 participants