Secrets Problems Again

I cloned an app.
This app had secrets.
I added a dependency app which also has secrets.
I deleted the main (cloned) app’s secrets as I wanted to use the dependency ones.

When I run the app I get :

anvil.secrets.SecretError: This app's secrets have been cleared. Please reset their values in the App Secrets config.

  <running on the server>
  called from /downlink/anvil/secrets.py, line 5
  called from library_mysql_tmx_api.DBBase.py, line 12
  called from Decorators, line 11
  called from Decorators, line 37
  called from Stats, line 78
  called from Stats, line 75
  called from Main, line 19

They definitely haven’t been cleared in the dependency app (library_mysql_tmx_api). I can see them.

Could the fact I had the secrets service from the original cloning be causing an issue?
Or do I have to reference the secrets differently when used this way?

The dependency app DBBase class refers to the secrets service in the dependency app itself, like this :

    self.dbhost =  anvil.secrets.get_secret('db_host')
    self.dbport = anvil.secrets.get_secret('db_port')
    self.username = anvil.secrets.get_secret('db_username')
    self.password = anvil.secrets.get_secret('db_password')

If it’s imported do I have to explicitly reference the dependency app?

(edit 1,767) - I think it is trying to refer to the main app. In fact, it definitely is. Nah, see answer below

If I re-add the secrets service it throws a whole load of other issues of course, but it shows that it’s referring to the local app and not the library.

How do I sort this out? Help! :slight_smile:

Fixed it.

Cloned it with git then removed the project’s secret service from anvil.yaml (a throwback to the app cloning I’m assuming).

Works fine now.

BUT - is there anyway to avoid such a palaver? It looks to me like deleting the secrets service leaves detritus under the bonnet which requires bowel surgery, if I may mix my metaphors.

Yeah, that sounds like a bug report! Deleting your app’s secrets should do the trick perfectly. Can you send us the app ID to support@anvil.works, and tell us the commit that fixed it? We’ll take a look at your Git repository and see what happened…

(There is a possibility this is still a holdover from your previous use of a beta version of the App Secrets service. We’ll check it out.)

I have investigated, and I think this seems to be a leftover issue from your use of the early beta Secrets Service. In particular, trying to access a secret in a cloned app correctly gives you the “Secrets have been cleared” error, but accessing a secret in a dependency works as long as the names don’t clash.

Please let us know if you’re able to reproduce, I’m going to close this for now.

1 Like