Can't select value for Foreign Key

I'm trying to set all the foreign keys, but when I'm trying to "Select a target" (so the primary key of another table) it just gives me an empty menu.
Like this:


It's an error? Or I'm missing something?
Thanks for the help!

Hi @SgheizaAriele
Post "Diagnostic Info" from Admin > Troubleshooting.
Have you defined the Entity Key on any of the other tables?

Here is the Diagnostic Info:
{
"browser-info": {
"language": "en-gb",
"platform": "MacIntel",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)",
"vendor": "Apple Computer, Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.7+9-202002041938",
"java.vendor": "AdoptOpenJDK",
"java.vendor.url": "https://adoptopenjdk.net/",
"java.version": "11.0.7",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.7+9-202002041938",
"os.name": "Mac OS X",
"os.version": "10.16",
"user.language": "en",
"user.timezone": "Europe/Zurich"
},
"metabase-info": {
"databases": [
"mysql",
"h2"
],
"hosting-env": "osx",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2021-10-06",
"tag": "v0.41.0",
"branch": "release-x.41.x",
"hash": "c529fe2"
},
"settings": {
"report-timezone": null
}
}
}

Now I'm just focused on two tables, the first that has the primary key and the second that has the foreign key. I set up the primary key in the first, but in the second it never pops up in the menu.

@SgheizaAriele
Let's call the tables Orders and Users, where Orders.User_ID should have a foreign key to Users.ID.
What is the Field Type for Users.ID ?
I don't know if it might be something specific with the MacApp, but try doing a page refresh. I would recommend using anything but the MacApp: https://www.metabase.com/learn/getting-started/installing

Now I downloaded Metabase with .jar file locally, and I get the same error.
All the primary keys are "Entity Key".

@SgheizaAriele
Okay, I would need to see the output of this request /api/database/123/metadata?include_hidden=true, where 123 is the database ID.
It sounds like the other fields or tables are hidden.

I'm sorry, where do I have to make this request?

@SgheizaAriele Replace with your Site URL and database ID.
https://metabase.example.com/api/database/123/metadata?include_hidden=true

It just gives me "API endpoint does not exist"

@SgheizaAriele Okay, something is really wrong with your setup then.
Please post "Diagnostic Info" from Admin > Troubleshooting.

{
"browser-info": {
"language": "fr-FR",
"platform": "MacIntel",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "16.0.2+7",
"java.vendor": "Eclipse Foundation",
"java.vendor.url": "https://adoptium.net/",
"java.version": "16.0.2",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "16.0.2+7",
"os.name": "Mac OS X",
"os.version": "11.5",
"user.language": "en",
"user.timezone": "Europe/Zurich"
},
"metabase-info": {
"databases": [
"h2",
"mysql"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2021-10-06",
"tag": "v0.41.0",
"branch": "release-x.41.x",
"hash": "c529fe2"
},
"settings": {
"report-timezone": null
}
}
}

Here it this, can't thank you enough for the help!

@SgheizaAriele Okay, please try Java 11. Java 16 is EOL and wasn't a LTS release.
https://www.metabase.com/docs/latest/operations-guide/java-versions.html
http://whichjdk.com/

And then go to Admin > Data Model > select your database in upper-left corner and then tell me the URL you're seeing.

I would almost recommend you just try the free trial of Metabase Cloud if your databases are accessible via the internet. https://www.metabase.com/pricing/

this is the URL: /admin/datamodel/database/3
I'm now using Java 11 and AWS (not local anymore).
Here is the new Diagnostic Info if you need it again:
{
"browser-info": {
"language": "fr-FR",
"platform": "MacIntel",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36",
"vendor": "Google Inc."
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.12+7",
"java.vendor": "Eclipse Foundation",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.12",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.12+7",
"os.name": "Linux",
"os.version": "4.14.246-187.474.amzn2.x86_64",
"user.language": "en",
"user.timezone": "GMT"
},
"metabase-info": {
"databases": [
"h2",
"mysql"
],
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
},
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
}
},
"run-mode": "prod",
"version": {
"date": "2021-10-06",
"tag": "v0.41.0",
"branch": "release-x.41.x",
"hash": "c529fe2"
},
"settings": {
"report-timezone": null
}
}
}

sorry for the late reply!

@SgheizaAriele Okay, then you need to go to this URL - replace with your Site URL:
https://metabase.example.com/api/database/3/metadata?include_hidden=true

If that doesn't work, then I have absolutely no idea what's wrong and you should try Metabase Cloud.

I have something!
this is just the beginning of the page:

{"description":null,"features":["basic-aggregations","standard-deviation-aggregations","expression-aggregations","foreign-keys","right-join","left-join","native-parameters","nested-queries","expressions","set-timezone","binning","inner-join","advanced-math-expressions"],"cache_field_values_schedule":"0 0 0 * * ? *","timezone":"+02:00","auto_run_queries":true,"metadata_sync_schedule":"0 49 * * * ? *","name":"FondationSI","caveats":null,"tables":[{"description":null,"entity_type":"entity/GenericTable","schema":null,"show_in_getting_started":false,"name":"blacklists","fields":[{"description":null,"database_type":"INT","semantic_type":"type/PK","table_id":250,"coercion_strategy":null,"name":"id","fingerprint_version":0,"has_field_values":"none","settings":null,"caveats":null,"fk_target_field_id":null,"updated_at":"2021-10-18T08:47:03.831","custom_position":0,"effective_type":"type/Integer","active":true,"parent_id":null,"id":3009,"last_analyzed":null,"position":0,"visibility_type":"normal","target":null,"preview_display":true,"display_name":"ID","database_position":0,"fingerprint":null,"created_at":"2021-10-18T08:47:03.831","base_type":"type/Integer","points_of_interest":null},
...

It's super long, it's probably all the tables in the database.

@SgheizaAriele Yes, it's large, since it's all tables and fields in the database.

But since I cannot reproduce the problem, then I have no other way than asking for a lot of data, so I hopefully can figure out the problem.

Should I copy all?

Just to wrap this up. It was caused by browser or browser extension.

1 Like

Hi there. I have the same issue. How was this fixed?

@joe.somewhere
Like I stated right above: It was caused by browser or browser extension.
So try another browser, or Incognito-mode without extensions.