Algolia move-index operation leaves restricted API keys bound to original index name
0 reputation · 15 Nov 2023, 06:55 UTC
0 reputation · 15 Nov 2023, 06:55 UTC
Algolia supports zero-downtime reindexing by copying records to a temporary index and then using the move-index operation to swap it into production. For a small application, this pattern avoids service interruption, but it exposes a permission boundary when clients use restricted API keys. Keys scoped to a specific index name—including secured API keys generated with restrictIndices—remain bound to the original index name after the move. Because Algolia does not provide index aliases, there is no native indirection layer to keep those credentials valid against the new physical index name.
The copy operation is asynchronous and does not guarantee a point-in-time snapshot if writes continue to the source index, so the migration window introduces additional consistency concerns. Before cutover, the application must decide how to handle credentials that reference the old index name, especially since previously issued secured API keys cannot be updated server-side and must be regenerated if the index name changes.
What is the recommended configuration for scoping new API keys to the target index before the move while ensuring old keys are retired only after all traffic has cut over? How should dual-writing during the copy window be coordinated with key rotation to avoid authorization gaps? Is there a documented way to verify that every existing key’s indexes field no longer references the released old index name before the move completes?
33275 reputation · 15 Nov 2023, 09:28 UTC
Pre-create new restricted API keys scoped to the target production index name before you call move-index, keep the old keys active during the copy window, and retire the old keys only after server-side logs confirm zero traffic using them. Dual-writes must be performed with a server-side key that can write to both source and temporary indexes. A complete pre-move inventory of all secured API keys is not possible in Algolia; verification relies on listing application-level restricted keys and client-side telemetry.
indexes field cannot be changed after issuance.restrictIndices inherit the parent key's restrictions and are immutable after issuance. They cannot be updated server-side.move-index replaces the destination index with the source and removes the source index name. Any credential that references the source name becomes invalid after the move.Because keys are bound to index names, a move changes the physical name that clients are allowed to access. There is no alias layer to keep old credentials working against the new physical index. Secured keys issued to clients remain tied to the names encoded at generation time.
indexes field. Use this only for the migration window.move-index from source to destination.Algolia does not provide a central inventory of all issued secured API keys. Application-level restricted API keys can be listed via the API Keys API and inspected for references to the soon-to-be-released source index name.
Practical verification steps:
indexes field for the old source name.Complete pre-move verification of every active secured key is not possible without client-side telemetry, because client-generated secured keys cannot be enumerated centrally.
Are secured API keys generated server-side per session or baked into client applications? If they are baked into clients, rotation requires a client release and the cutover plan must include a longer overlap window and feature flag.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.