Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'details' for internal Metabase tables #307

Closed
alex1bravo opened this issue Jan 27, 2025 · 1 comment · Fixed by #308
Closed

KeyError: 'details' for internal Metabase tables #307

alex1bravo opened this issue Jan 27, 2025 · 1 comment · Fixed by #308
Labels
bug Something isn't working

Comments

@alex1bravo
Copy link

In the _exposures.py at a certain point you have the following code:

            table_names={
                t["id"]: ".".join(
                    [
                        dbname(t["db"]["details"]),
                        t["schema"] or DEFAULT_SCHEMA,
                        t["name"],
                    ]
                ).lower()
                for t in self.metabase.get_tables()
            },

It seems that recently the Metabase API, when you run self.metabase.get_tables(), returns also some internal tables. For example, this table here

{
  "description": null,
  "entity_type": "entity/GenericTable",
  "view_count": 0,
  "schema": "public",
  "database_require_filter": null,
  "db": {
    "uploads_schema_name": null,
    "description": "Internal Audit DB used to power metabase analytics.",
    "features": [
      "describe-fks",
      "index-info",
      "full-join",
      "window-functions/cumulative",
      "test/dynamic-dataset-loading",
      "describe-fields",
      "basic-aggregations",
      "temporal-extract",
      "identifiers-with-spaces",
      "actions/custom",
      "window-functions/offset",
      "now",
      "parameterized-sql",
      "convert-timezone",
      "nested-field-columns",
      "standard-deviation-aggregations",
      "test/jvm-timezone-setting",
      "date-arithmetics",
      "persist-models",
      "actions",
      "expression-aggregations",
      "percentile-aggregations",
      "connection-impersonation",
      "table-privileges",
      "right-join",
      "left-join",
      "native-parameters",
      "uuid-type",
      "schemas",
      "nested-queries",
      "describe-indexes",
      "expressions",
      "uploads",
      "set-timezone",
      "regex",
      "case-sensitivity-string-filter-options",
      "binning",
      "metadata/key-constraints",
      "datetime-diff",
      "upload-with-auto-pk",
      "inner-join",
      "advanced-math-expressions",
      "fingerprint",
      "native-parameter-card-reference"
    ],
    "uploads_table_prefix": null,
    "cache_field_values_schedule": "0 0 16 * * ? *",
    "timezone": null,
    "is_attached_dwh": false,
    "auto_run_queries": true,
    "metadata_sync_schedule": "0 27 * * * ? *",
    "name": "Internal Metabase Database",
    "settings": null,
    "caveats": null,
    "creator_id": 13371338,
    "is_full_sync": true,
    "updated_at": "2025-01-16T00:24:48.771475Z",
    "cache_ttl": null,
    "is_sample": false,
    "id": 13371337,
    "is_on_demand": false,
    "engine": "postgres",
    "initial_sync_status": "complete",
    "is_audit": true,
    "dbms_version": null,
    "uploads_enabled": false,
    "refingerprint": null,
    "created_at": "2024-01-18T00:12:05.675943Z",
    "points_of_interest": null
  },
  "show_in_getting_started": false,
  "name": "v_alerts",
  "caveats": null,
  "updated_at": "2025-01-16T00:24:48.771475Z",
  "active": true,
  "id": 274,
  "db_id": 13371337,
  "visibility_type": null,
  "field_order": "database",
  "is_upload": false,
  "initial_sync_status": "complete",
  "display_name": "V Alerts",
  "created_at": "2023-11-01T02:10:33.263249Z",
  "estimated_row_count": null,
  "points_of_interest": null
}

So, when you do t["db"]["details"], it breaks because it cannot find the details key.

IDK what a possible solution could be, but probably just ignore these Metabase internal tables. It could be done by filtering out the tables when the database name is Internal Metabase Database. IDK how reliable this solution is tho, or how likely is that Metabase will change the API behavior in the next future.

Let me know if I can help with this, thanks for the support!

@gouline gouline added the bug Something isn't working label Jan 30, 2025
@gouline
Copy link
Owner

gouline commented Jan 30, 2025

I tracked it down to a Metabase pull request about auditing, which is an enterprise feature, so I can't reproduce it in the open source sandbox. Not sure how to best filter it, I just added a check for "details" 🤷‍♂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants