strapi/strapi · error · ProviderValidationError
Invalid strategy ${strategy}
Error message
Invalid strategy ${strategy} What it means
Thrown by createConfigurationWriteStream() if options.strategy is not 'restore'. Like error 265, this is a defensive fallback after the `if (strategy === 'restore')` check. It should be unreachable if bootstrap() validated options successfully, and indicates options.strategy was mutated or bootstrap was skipped. It is a ProviderValidationError.
Source
Thrown at packages/core/data-transfer/src/strapi/providers/local-destination/index.ts:344
return createAssetsDestinationWritable({
strapi: this.strapi,
transaction: this.transaction!,
resolveUploadFileId: (metadata) => fileEntitiesMapper?.[metadata.id],
restoreMediaEntitiesContent: this.#isContentTypeIncluded('plugin::upload.file'),
removeAssetsBackup: this.#removeAssetsBackup.bind(this),
});
}
async createConfigurationWriteStream(): Promise<Writable> {
assertValidStrapi(this.strapi, 'Not able to stream Configurations');
this.#reportInfo('creating configuration write stream');
const { strategy } = this.options;
if (strategy === 'restore') {
return restore.createConfigurationWriteStream(this.strapi, this.transaction);
}
throw new ProviderValidationError(`Invalid strategy ${strategy}`, {
check: 'strategy',
strategy,
validStrategies: VALID_CONFLICT_STRATEGIES,
});
}
async createLinksWriteStream(): Promise<Writable> {
this.#reportInfo('creating links write stream');
if (!this.strapi) {
throw new Error('Not able to stream links. Strapi instance not found');
}
const { strategy } = this.options;
const mapID = (uid: string, id: number): number | undefined => this.#entitiesMapper[uid]?.[id];
if (strategy === 'restore') {
return restore.createLinksWriteStream(mapID, this.strapi, this.transaction, this.onWarning);
}View on GitHub (pinned to 4a4101264d)
Solutions
- Call and await bootstrap() before createConfigurationWriteStream().
- Do not mutate provider.options.strategy after construction.
- Set strategy to 'restore' before creating the provider.
Example fix
// before await provider.bootstrap(); // not called provider.createConfigurationWriteStream(); // throws // after await provider.bootstrap(); provider.createConfigurationWriteStream();
Defensive patterns
Strategy: validation
Validate before calling
import { VALID_CONFLICT_STRATEGIES } from '@strapi/data-transfer/strapi/providers/local-destination';
function assertStrategyForConfig(strategy: string): void {
if (!VALID_CONFLICT_STRATEGIES.includes(strategy as any)) {
throw new Error(`Cannot create configuration stream: invalid strategy "${strategy}"`);
}
} Try / catch
try {
provider.createConfigurationWriteStream();
} catch (e) {
if (e instanceof Error && e.message.startsWith('Invalid strategy')) {
console.error('Ensure bootstrap() was called and strategy was not mutated.');
} else {
throw e;
}
} Prevention
- Always call bootstrap() before createConfigurationWriteStream().
- Never mutate provider.options.strategy after construction.
- Follow the full provider lifecycle in order.
When it happens
Trigger: Calling createConfigurationWriteStream() without calling bootstrap(), or mutating provider.options.strategy to a non-'restore' value after bootstrap validation.
Common situations: A custom pipeline that skips bootstrap(). External code modifying options.strategy between phases. Test harnesses calling streaming methods in isolation.
Related errors
- Invalid strategy ${this.options.strategy}
- Missing restore options
- Attempting to transfer assets when `assets` is not set in re
- lifespan must be a positive number or null
- Unknown permissions provided: ${invalidPermissions.join(', '
AI-assisted analysis of strapi/strapi@4a4101264d (2026-08-12).
Data as JSON: /api/errors/4005cb3a9c321f11.
Report an issue: GitHub.