Voice Studio "Save design as profile" passed buildDesignInstruct()'s RETURN
OBJECT ({instruct, unsupported, duplicates}) straight to FormData.append, which
string-coerced it to the literal "[object Object]". That got persisted into
voice_profiles.instruct and 400'd on first preview/use with "Unsupported instruct
items found in [object Object]" (#550 #545 #542 #537 #530 #525).
Fix the whole class + heal already-poisoned data (backward-compatible-data rule):
- CloneDesignTab.jsx:609 — pass `.instruct` (the string), not the builder object.
- useProfiles.js — append via new instructToFormValue() helper, which extracts
`.instruct` if an object ever slips through again (defense-in-depth).
- omnivoice/_resolve_instruct — drop the "[object Object]" sentinel instead of
raising, so any value that slips through (e.g. generation_history) degrades to
neutral conditioning rather than a hard 400. A genuine unsupported token still
raises (keeps the #114/#115 user feedback).
- migration 0006 — UPDATE voice_profiles SET instruct='' WHERE it's the sentinel,
idempotent + table-guarded, to heal profiles saved on the buggy build.
Tests (fail-before/pass-after): frontend voiceInstruct (instructToFormValue never
yields "[object Object]"); backend _resolve_instruct tolerates the sentinel but
still rejects a real bad token; alembic 0006 heals a poisoned row, leaves a
healthy one untouched. Frontend 9 passed + typecheck clean; backend 5 passed.
Co-authored-by: mergetest <test@local>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
"""Heal voice_profiles.instruct poisoned with the "[object Object]" sentinel.
|
|
|
|
Revision ID: 0006_strip_object_object_instruct
|
|
Revises: 0005_unified_profiles
|
|
Create Date: 2026-06-20 00:00:00.000000
|
|
|
|
A pre-fix Voice Studio build ("Save design as profile") passed the
|
|
``buildDesignInstruct()`` *object* straight to FormData, which string-coerced it
|
|
to the literal ``"[object Object]"`` and persisted that into
|
|
``voice_profiles.instruct`` (#550 #545 #542 #537 #530 #525). On first
|
|
preview/use that value fails the engine instruct validator with a 400. The
|
|
frontend + backend fixes stop any NEW poisoned rows; this migration heals the
|
|
ones already saved on the buggy build (the local-first backward-compat rule —
|
|
existing project data must keep working without manual migration).
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
from sqlalchemy import inspect
|
|
|
|
revision: str = "0006_strip_object_object_instruct"
|
|
down_revision: Union[str, None] = "0005_unified_profiles"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
if "voice_profiles" in inspect(bind).get_table_names():
|
|
# Idempotent: only touches rows whose instruct is literally the sentinel.
|
|
op.execute("UPDATE voice_profiles SET instruct='' WHERE instruct='[object Object]'")
|
|
|
|
|
|
def downgrade() -> None:
|
|
# Irreversible heal — the original garbage sentinel is not worth restoring.
|
|
pass
|