fix: STT audioFormat scoping, automation import name, orphan FK cleanup

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
patrick-motsch 2026-02-13 18:03:23 +01:00
parent 367edd83e2
commit 77151df0f4
3 changed files with 21 additions and 2 deletions

View file

@ -86,6 +86,9 @@ class ConnectorGoogleSpeech:
channels = validation["channels"]
audioFormat = validation["format"]
logger.info(f"Auto-detected audio: {audioFormat}, {sampleRate}Hz, {channels}ch")
else:
# When sampleRate and channels are explicitly provided, assume raw PCM (LINEAR16)
audioFormat = "linear16"
logger.info(f"Processing audio with Google Cloud Speech-to-Text")
logger.info(f"Audio: {len(audioContent)} bytes, {sampleRate}Hz, {channels}ch")

View file

@ -301,12 +301,12 @@ def _migrateExistingTemplates() -> None:
as system templates (isSystem=True). This runs idempotently during feature registration.
"""
try:
from modules.features.automation.interfaceFeatureAutomation import getAutomationInterface
from modules.features.automation.interfaceFeatureAutomation import getInterface
from modules.security.rootAccess import getRootUser
from modules.features.automation.datamodelFeatureAutomation import AutomationTemplate
rootUser = getRootUser()
automationInterface = getAutomationInterface(rootUser)
automationInterface = getInterface(rootUser)
# Get all templates from DB
allTemplates = automationInterface.db.getRecordset(AutomationTemplate)

View file

@ -390,6 +390,22 @@ def _applyForeignKeys(cursor, tables: Optional[List[str]]) -> int:
logger.warning(f"Failed to drop FK {constraintName}: {e}")
continue
# Clean up orphaned rows before applying FK constraint
try:
cursor.execute(f"""
DELETE FROM "{tableName}"
WHERE "{column}" IS NOT NULL
AND "{column}" NOT IN (SELECT "id" FROM "{refTable}")
""")
orphanCount = cursor.rowcount
if orphanCount > 0:
logger.info(
f"Cleaned {orphanCount} orphaned row(s) from {tableName} "
f"(missing {refTable} reference via {column})"
)
except Exception as e:
logger.warning(f"Failed to clean orphans for FK {constraintName}: {e}")
try:
cursor.execute(f"""
ALTER TABLE "{tableName}"