Summary
@metabase/database-metadata extract-table-metadata doesn't emit fk_target_field_id for any field, and doesn't emit semantic_type when its value is type/FK (though it does correctly emit type/PK). Both attributes are explicitly described in core-spec/v1/spec.md.
Reproduction
- Configure a foreign key in Metabase via the admin UI (any FK on any column with
semantic_type: type/FK and a populated fk_target_field_id).
curl /api/database/<id>/metadata?include_hidden=true — confirm the response includes the field with "semantic_type":"type/FK" and "fk_target_field_id":<numeric>.
npx @metabase/database-metadata extract-table-metadata <that-json> <output-dir>.
- Open the extracted YAML for the table containing the FK column: neither
semantic_type: nor fk_target_field_id: appears.
Reproduced against a current Metabase Enterprise instance with 3 manually-set FKs on the schema in scope. Raw /api/database/<id>/metadata?include_hidden=true returns all three FKs correctly; extracted YAML has none of them.
Expected
Per core-spec/v1/spec.md:
semantic_type | string | No | Business-domain label (e.g., type/PK, type/Email).
fk_target_field_id | array | No | Field FK of the referenced primary-key column, for fields with semantic_type: type/FK.
Both should be emitted when present in the API response. fk_target_field_id should be the natural-key tuple [db_name, schema, table, field, ...nested], not the raw numeric id.
Impact
Anyone using the extractor to maintain a YAML source of truth for their Metabase metadata loses every FK relationship on every sync. We worked around this by injecting both attributes post-extract in our own tooling, resolving the numeric id to the natural-key tuple via the raw JSON.
Version
@metabase/database-metadata latest from npm as of 2026-05-15.
Summary
@metabase/database-metadata extract-table-metadatadoesn't emitfk_target_field_idfor any field, and doesn't emitsemantic_typewhen its value istype/FK(though it does correctly emittype/PK). Both attributes are explicitly described incore-spec/v1/spec.md.Reproduction
semantic_type: type/FKand a populatedfk_target_field_id).curl /api/database/<id>/metadata?include_hidden=true— confirm the response includes the field with"semantic_type":"type/FK"and"fk_target_field_id":<numeric>.npx @metabase/database-metadata extract-table-metadata <that-json> <output-dir>.semantic_type:norfk_target_field_id:appears.Reproduced against a current Metabase Enterprise instance with 3 manually-set FKs on the schema in scope. Raw
/api/database/<id>/metadata?include_hidden=truereturns all three FKs correctly; extracted YAML has none of them.Expected
Per
core-spec/v1/spec.md:Both should be emitted when present in the API response.
fk_target_field_idshould be the natural-key tuple[db_name, schema, table, field, ...nested], not the raw numeric id.Impact
Anyone using the extractor to maintain a YAML source of truth for their Metabase metadata loses every FK relationship on every sync. We worked around this by injecting both attributes post-extract in our own tooling, resolving the numeric id to the natural-key tuple via the raw JSON.
Version
@metabase/database-metadatalatest from npm as of 2026-05-15.