Dropdown filters display as text fields once embedded

Hi,

We're experiencing and issue where filters that are set as dropdowns in the Metabse UI are displaying as text fields when embedded in our app.

This is happening to multiple filters, but not to all of them. Additionally, one of the dropdown filters shows one option when there should be four.

Here are screenshots of the two scenarios:

We have tried:

  • Clearing the field caches in Admin > Table Metadata
  • Adding custom values to the dropdown list
  • Changing the table type to ENUM instead of Category
  • Unlocking the Locked filter

Further details:

  • Database: Postgres
  • Embedding method: Python

Strangely it seems that the API actually returns an empty array for the filter values:

Entering a value that exists into the filter does work and results are filtered accordingly.

Diagnostic info:

{
  "browser-info": {
    "language": "en-ZA",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.24+8",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.24",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.24+8",
    "os.name": "Linux",
    "os.version": "5.15.0-1053-aws",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "postgres",
      "h2"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "16.1 (Debian 16.1-1.pgdg120+1)"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.7.3"
      }
    },
    "run-mode": "prod",
    "plan-alias": "",
    "version": {
      "date": "2024-08-13",
      "tag": "v0.50.20",
      "hash": "df82d58"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Thanks in advance for your time!

Do you have any linked filters associated with these drop down filters?

Also are those Questions in the Dashboard SQL questions, GUI questions and are they based on models, other questions or tables. Can you share some screenshot of that setup.

I would start by having a dashboard with just 1 question first and then link the appropriate filters so its easier to debug. It could be 1 question is interfering with all the other questions int he dashboard

Hey Tony,

Thanks for your response!

No, we do not have any linked filters.

These are all SQL questions. I am not sure exactly what you'd like to see a screenshot of in regards to that?

This same thing is actually happening in another app of ours that embeds from a different instance of Metabase.

What is very strange here is that the Metabase API actually returns an empty array for the affected filters and those filters work if an appropriate value is manually entered.

yeah my assumption is that metabase is simply not able to detect the proper column. Do you have a lot of joins around the field filter you are using and are these FKs properly mapped in the Admin -> Table Metadata

So i would start with removing all cards and just leave 1 and see if that happens for just 1 card then start adding back 1 card at a time. It could be 1 card (question) is the problem. Can you try please

Hey Tony,

Ok, we have mad a very basic dashboard with a basic query and only two filters and the issue persists.

Here is the Metabase dash showing the two filters and the status filter correctly populated:

Here is the embedded view showing the status filter with only one of three options (in other cases this shows as a text field):

I think we have narrowed it down to a specific scenario though.

Our app is a 'multi-tenanted' app with multiple organisations and we pre-filter results per org by dynamically passing in the org param via the backend. We make the org filter a locked param in the embed settings (screenshot below).

Making the org filter Editable in the embed settings doesn't make any difference.

If we remove the org filter from the query then the embedded version gets all the dropdown options.

Here is how we are handling the param injection via the backend:

Thanks for your time!

Hey,

Just bumping this topic. Should I create a bug on Github for this perhaps?

Not sure if you ever got this resolved?

I’m very new to Metabase but noticed a similar behaviour today with an embedded locked linked filter (i.e. a names dropdown is rendered as a Search dialog) but ONLY if our initial params payload has multiple values supplied. With a single parameter it behaves as expected.

Can see an error in the Inspect Network profile Preview: “Error preprocessing query in metabase.query-processor.middleware.auto-parse-filter-values/auto-parse-filter-values: Error filtering against :type/Integer Field: unable to parse String "55,65" to a :type/Integer “

Seems like a bug to me as the filtering works as expected embedded with a single value or with multiple values in Metabase UI.

Anyone else seen similar or know how to resolve?

Where does the “55,65” come from? Is that supposed to be two values, or a floating-point value because you use comma as a decimal separator?

Sorry, yes, that’s meant that to be two values i.e.

  • “55,65” is a comma separated list of two user_id integer values
  • “45,55,65” is a comma separated list of three user_id integer values

IIRC if you are setting multiple values for a locked filter, you have to use a JSON array in the JWT.

So much terminology for a Metabase newbie to pickup!

I agree that passing multiple values to a locked dashboard field-filter appears to be possible using an array of values in the JWT.
For a SQL variable parameter which is expecting a list of values for an IN clause this seems to fail. Perhaps it’s just not possible - I found this comment in Parameters for static embeds | Metabase Documentation
Locked parameters on dashboards with SQL questions

If your locked parameter is linked to a dashboard filter that’s in turn linked to a SQL question, you’ll only be able to choose a single value for your locked parameter.

For example, let’s say you have a dashboard filter called “Breakfast” with the values “Hash browns”, “Muffin”, and “Waffles”. If the “Breakfast” filter is linked to any SQL questions on the dashboard, you’ll only be able to choose one of the options for a locked parameter linked to the “Breakfast” filter.”