System.url-prefix multiple entries after upgrade?

I just upgraded Sentry from 9.1.2 to 20.12.1 on Kubernetes and it all worked fine.

However, when I try to change certain settings (like enabling SAML, among others), I get a server error. Looking at the sentry-web logs, it’s always the same;

[ERROR] sentry: option.failed-lookup (key=‘system.url-prefix’)

It appears that this value does not exist, but should? How can I fix this?

Addendum; this one also shows up a bunch:

[ERROR] sentry: option.failed-lookup (key=‘sentry:latest_version’)

Further digging revealed that sentry.url-prefix and sentry:latest_version both exist in the sentry_options table TWICE - both with the same ID as well.

The table also has no primary key, no other indices or anything, making it virtually impossible to delete 1 of 2 identical rows.

I think something went very wrong here during the migrations. Is there a way to fix this?

Some more;

SELECT "key", COUNT(*) FROM sentry_option GROUP BY "key" HAVING COUNT(*) > 1;

gives;

"sentry:install-id"	2
"sentry:system-token"	2
"auth.allow-registration"	2
"sentry:last_worker_ping"	4
"sentry:last_worker_version"	4
"sentry:latest_version"	2
"system.admin-email"	2
"sentry:version-configured"	2
"beacon.anonymous"	2
"system.url-prefix"	2

You may be able to use the following method: https://stackoverflow.com/a/5171473/90297

Also, if you delete all these values, I think some will be taken from the disk and you’ll be prompted for the others at your first admin login. I’d still take a backup of the table before trying the deletion option.

I eventually managed to fix this by installing a bare Sentry and importing the data into that DB while ignoring errors. It was a bit of a hassle, but it worked out.

1 Like