linshenkx/prompt-optimizer · warning · FavoriteValidationError
Target tag cannot be empty
Error message
Target tag cannot be empty
What it means
FavoriteValidationError thrown by mergeTags when targetTag is falsy — the destination tag for the merge must be a non-empty string.
Source
Thrown at packages/core/src/services/favorite/manager.ts:1046
return tagsList;
});
}
await this.updateStats();
return affectedCount;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
throw new FavoriteStorageError(`Failed to rename tag: ${errorMessage}`);
}
}
async mergeTags(sourceTags: string[], targetTag: string): Promise<number> {
if (!sourceTags || sourceTags.length === 0) {
throw new FavoriteValidationError('Source tag list cannot be empty');
}
if (!targetTag) {
throw new FavoriteValidationError('Target tag cannot be empty');
}
let affectedCount = 0;
try {
// 1. 更新独立标签库:删除所有源标签,确保目标标签存在
await this.storageProvider.updateData(this.STORAGE_KEYS.TAGS, (tags: FavoriteTag[] | null) => {
const tagsList = tags || [];
// 删除所有源标签
const filteredTags = tagsList.filter(t => !sourceTags.includes(t.tag));
// 确保目标标签存在
const hasTargetTag = filteredTags.some(t => t.tag === targetTag);
if (!hasTargetTag) {
filteredTags.push({
tag: targetTag,
createdAt: Date.now()View on GitHub (pinned to 3e677b1d9f)
Solutions
- Validate targetTag is a non-empty string before merging
- Default the target to one of the source tags in UI flows
Example fix
// before
await manager.mergeTags(sources, target);
// after
if (sources.length && target) {
await manager.mergeTags(sources, target);
} Defensive patterns
Strategy: validation
Validate before calling
if (targetTag) await manager.mergeTags(sourceTags, targetTag);
Prevention
- Default the merge target to a selected source tag
When it happens
Trigger: Calling mergeTags(['a'], '') or passing null/undefined as targetTag.
Common situations: Merge dialog with an unset target; target cleared by user before submission.
Related errors
- Source tag list cannot be empty
- Tag name cannot be empty
- Failed to merge tags: ${errorMessage}
- Cannot delete the last prompt asset version
- Cannot delete the current prompt asset version
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/9c408ef4da0a3f35.
Report an issue: GitHub.