Probable Bug: anvil.users.login_with_form crashes lately

What I’m trying to do:

Just trying to show the login-form:

anvil.users.login_with_form(allow_cancel=True)

I am doing this in def form_show(self, **event_args) of a form that is shown inside of a container of my main form.

This used to work without issues for years :sweat_smile:, now I suddenly get the following error:

: Object Not Found Matching Id:2
RuntimeError: This component is already added to a container, or is already inside an alert
at anvil-services/anvil/users/__init__.py, line 556
called from Verbesserungsvorschlaege, line 385

The app is still running Python 2.7. Sadly I can’t offer to clone it.

Please help!

Thanks for reporting. Can you provide a little more information?

Is this sporadic or every time?
Does it happen in a minimal example? Or only in your full app?
If it does happen in a minimal example please provide a clone link to the example.
Does it happen in production or only in the ide?
Since when did you notice the issue?

It seems to happen every few days at least. First time it happened - if I can trust the log search (which I can’t as described here) - was on Fri 18th Nov 2022.

It happens in production. I haven’t tried to replicate it with a minimal example yet.

It also sometimes happens when anvil.users.login_with_form(allow_cancel=True) is called from inside my main form module.

RuntimeError: This component is already added to a container, or is already inside an alert
at anvil-services/anvil/users/__init__.py, line 556
called from Nav, line 392
called from Nav, line 293
called from Nav, line 88

thanks - could you provide more code snippets to show how you’re using anvil.users.login_with_form(allow_cancel=True) in context so we can try to reproduce.

Simple attempts to reproduce haven’t worked.

Have you been able to reproduce this yourself?
Or only from logging output?

edit:
Anything that gives us a reliable way to reproduce this would be handy

Yeah, same here. I’ve only ever seen this in the logs, haven’t been able to reproduce it either.

For sure. Here are two instances:

  def stapel_link_click(self, set_history=True, **event_args):
    """This method is called when the link is clicked"""
    global busy
    if not busy:      
      busy = True
      self.deselect_all_links()
      self.stapel_link.role = 'selected'
      
      if self.get_user() == None:
        anvil.users.login_with_form(allow_cancel=True)
  def form_show(self, **event_args):

    # [...] Removed some irrelevant code here

    if self.get_user() == None:
      anvil.users.login_with_form(allow_cancel=True)

I haven’t had this problem since the beginning of March now (at least if you trust the search function of the App Logs), so it seems to be fixed. :tada:

Edit: Just checked but the search function is still unreliable, so it might not be fixed.