{"record":{"id":"62ad0c47e4593775","repo":"apache/beam","slug":"primary-key-field-is-required-when-action-ignore","errorCode":null,"errorMessage":"primary_key_field is required when action='IGNORE'","messagePattern":"primary_key_field is required when action='IGNORE'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/rag/ingestion/mysql_common.py","lineNumber":433,"sourceCode":"        >>> ConflictResolution(\n        ...     action=\"IGNORE\", \n        ...     primary_key_field=\"id\"\n        ... )\n        \n        Ignore conflicts with custom primary key:\n        >>> ConflictResolution(\n        ...     action=\"IGNORE\",\n        ...     primary_key_field=\"custom_id\"\n        ... )\n    \"\"\"\n  action: Literal[\"UPDATE\", \"IGNORE\"] = \"UPDATE\"\n  update_fields: Optional[list[str]] = None\n  primary_key_field: Optional[str] = None\n\n  def __post_init__(self):\n    \"\"\"Validate configuration after initialization.\"\"\"\n    if self.action == \"IGNORE\" and self.primary_key_field is None:\n      raise ValueError(\"primary_key_field is required when action='IGNORE'\")\n","sourceCodeStart":415,"sourceCodeEnd":434,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/rag/ingestion/mysql_common.py#L415-L434","documentation":"ConflictResolution.__post_init__ enforces that when action='IGNORE' a primary_key_field is supplied, because IGNORE-strategy deduplicates conflicting rows by matching the primary key. Without it the ignore semantics cannot be implemented, so configuration fails at construction.","triggerScenarios":"Constructing ConflictResolution(action='IGNORE') without primary_key_field — either omitted or left as its default None.","commonSituations":"Switching action from 'UPDATE' (which needs update_fields, not primary_key_field) to 'IGNORE' without adding the key field; building the config from YAML/JSON where the primary key entry is missing.","solutions":["Set primary_key_field to the table's primary key column name when using action='IGNORE'.","Verify the field name matches a column in your column_specs/table.","If you actually want upsert semantics, use action='UPDATE' with update_fields instead."],"exampleFix":"// before\nConflictResolution(action=\"IGNORE\")\n// after\nConflictResolution(action=\"IGNORE\", primary_key_field=\"id\")","handlingStrategy":"validation","validationCode":"if cr.action == 'IGNORE' and not cr.primary_key_field:\n    raise ValueError(\"primary_key_field required for IGNORE conflict resolution\")","typeGuard":"def ignore_is_valid(cr) -> bool:\n    return cr.action != \"IGNORE\" or cr.primary_key_field is not None","tryCatchPattern":"try:\n    cr = ConflictResolution(action=\"IGNORE\", **kw)\nexcept ValueError as e:\n    if \"primary_key_field is required\" in str(e):\n        cr = ConflictResolution(action=\"IGNORE\", primary_key_field=\"id\", **kw)\n    else:\n        raise","preventionTips":["Pair every action='IGNORE' with primary_key_field in your config templates","Validate conflict-resolution config at pipeline startup","Document per-action required fields (UPDATE->update_fields, IGNORE->primary_key_field)"],"tags":["python","mysql","rag","config-validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}