Edgewall Software

Opened 5 years ago

Last modified 4 years ago

#13165 closed defect

tracd incorrectly says "needs to be upgraded" if an exception is raised from needs_upgrade() — at Initial Version

Reported by: Jun Omae Owned by:
Priority: normal Milestone: 1.3.4
Component: general Version: 1.3dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Environment.needs_upgrade() raised a TypeError because installed plugin has incompatible method with Trac 1.3.x:

TypeError: environment_needs_upgrade() takes exactly 2 arguments (1 given)

When the error is raised, I get "needs to be upgraded" from tracd. It's incorrect, because the Trac environment is up-to-date.

Trac Error

TracError: The Trac Environment needs to be upgraded. Run:

  trac-admin "/home/jun66j5/var/trac/1.3-sqlite" upgrade

It seems the behavior is introduced in [15939] (#12680).

I consider that we should raise a TracError with Unable to check for upgrade message when an exception is raised from needs_upgrade():

  • trac/env.py

    diff --git a/trac/env.py b/trac/env.py
    index bf3fbb11c..0a6b868a9 100644
    a b def open_environment(env_path=None, use_cache=False):  
    857857                CacheManager(env).reset_metadata()
    858858    else:
    859859        env = Environment(env_path)
    860         needs_upgrade = True
    861860        try:
    862861            needs_upgrade = env.needs_upgrade()
     862        except TracError as e:
     863            env.log.error("Exception caught while checking for upgrade: %s",
     864                          exception_to_unicode(e))
     865            raise
    863866        except Exception as e:  # e.g. no database connection
    864867            env.log.error("Exception caught while checking for upgrade: %s",
    865868                          exception_to_unicode(e, traceback=True))
    866         if needs_upgrade:
    867             raise TracError(_('The Trac Environment needs to be upgraded. '
    868                               'Run:\n\n  trac-admin "%(path)s" upgrade',
    869                               path=env_path))
     869            raise TracError(_("Unable to check for upgrade: %(err)s",
     870                              err=exception_to_unicode(e)))
     871        else:
     872            if needs_upgrade:
     873                raise TracError(_('The Trac Environment needs to be upgraded. '
     874                                  'Run:\n\n  trac-admin "%(path)s" upgrade',
     875                                  path=env_path))
    870876
    871877    return env
    872878

After the patch, tracd says in this case:

Trac Error

TracError: Unable to check for upgrade: TypeError: environment_needs_upgrade() takes exactly 2 arguments (1 given)}

Change History (0)

Note: See TracTickets for help on using tickets.