{"record":{"id":"2911e7232fc44078","repo":"cocoindex-io/cocoindex","slug":"unexpected-column-subkey-format-sub-key-r-expe-2911e7","errorCode":null,"errorMessage":"Unexpected column subkey format: {sub_key!r}, expected to start with {_COL_SUBKEY_PREFIX!r}","messagePattern":"Unexpected column subkey format: (.+?), expected to start with (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/snowflake/_target.py","lineNumber":598,"sourceCode":"    if_not_exists_sql = \" IF NOT EXISTS\" if if_not_exists else \"\"\n    qualified_name = _qualified_table_name(key.database, key.schema, key.table_name)\n    columns_sql = \", \".join(col_defs)\n    cursor.execute(f\"CREATE TABLE{if_not_exists_sql} {qualified_name} ({columns_sql})\")\n\n\ndef _apply_column_actions(\n    cursor: Any,\n    key: _TableKey,\n    schema: TableSchema[Any],\n    column_actions: dict[str, statediff.DiffAction],\n) -> None:\n    qualified_name = _qualified_table_name(key.database, key.schema, key.table_name)\n    pk_cols = set(schema.primary_key)\n    non_pk_col_by_name = {n: c for n, c in schema.columns.items() if n not in pk_cols}\n\n    for sub_key, action in column_actions.items():\n        if not sub_key.startswith(_COL_SUBKEY_PREFIX):\n            raise ValueError(\n                f\"Unexpected column subkey format: {sub_key!r}, expected to start with {_COL_SUBKEY_PREFIX!r}\"\n            )\n        col_name = sub_key[len(_COL_SUBKEY_PREFIX) :]\n        if col_name in pk_cols:\n            continue\n\n        if action == \"delete\":\n            cursor.execute(\n                f'ALTER TABLE {qualified_name} DROP COLUMN IF EXISTS \"{col_name}\"'\n            )\n            continue\n\n        desired_col = non_pk_col_by_name.get(col_name)\n        if desired_col is None:\n            continue\n\n        if action == \"insert\":\n            cursor.execute(","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/snowflake/_target.py#L580-L616","documentation":"Column-level actions are keyed by sub-keys that must carry the reserved `_COL_SUBKEY_PREFIX` so `_apply_column_actions` can strip the prefix to recover the column name. A sub-key without the prefix means the action key format is not what the connector produced — an internal invariant violation — so it raises immediately rather than misinterpreting the key.","triggerScenarios":"`_apply_actions` receives a column_actions dict containing a key that doesn't start with the internal prefix, e.g. a raw column name passed instead of the prefixed sub-key — normally only possible when custom/patched code constructs the actions dict.","commonSituations":"Hand-rolled or monkey-patched action generation, version mismatch between a custom handler that builds sub-keys and the current connector format.","solutions":["Use the connector's own action-building helpers so sub-keys are created with _COL_SUBKEY_PREFIX instead of constructing them manually.","Prefix the raw column name with _COL_SUBKEY_PREFIX if you build column actions yourself.","Align package versions if a custom fork emits the old sub-key format; report upstream if triggered by stock code."],"exampleFix":"// before\ncolumn_actions[row[\"colname\"]] = action\n// after\ncolumn_actions[_COL_SUBKEY_PREFIX + row[\"colname\"]] = action","handlingStrategy":"validation","validationCode":"bad = [k for k in column_actions if not k.startswith(_COL_SUBKEY_PREFIX)]\nif bad:\n    raise ValueError(f\"Column action keys missing prefix: {bad}\")","typeGuard":null,"tryCatchPattern":"try:\n    apply_actions(...)\nexcept ValueError as e:\n    if \"Unexpected column subkey format\" in str(e):\n        logging.error(\"Stale/custom action key format: %s\", e)\n        raise\n    raise","preventionTips":["Never construct column action dicts by hand; use the connector's own helpers.","Keep the cocoindex package version consistent across environments.","Add a startup smoke test that performs a tiny sync against a temp table."],"tags":["snowflake","internal-invariant","key-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}