Trac 1.4.2 - doesn't handle spaces in Milestone names?

61 views
Skip to first unread message

Rob Hills

unread,
Dec 23, 2020, 3:18:11 PM12/23/20
to Trac Users

I've just managed to upgrade a long-running Trac instance from a very old version of Trac (0.12 IIRC) to 1.4.2 and it's mostly gone well.

However, in our Issue Tracker, all our Milestone names have spaces in them and this is causing problems.

On our Roadmap page, links to milestones include url-encoded spaces, but these cause broken links.  For example, clicking on our "Release Edition 5.3" takes me to a New Milestone page with the following message at the top:
Milestone Release%20Edition%205.3 does not exist. You can create it here.

Is there something I have missed in the configuration or does Trac no longer permit spaces in Milestone names?

TIA,

Rob Hills
Waikiki, Western Australia

RjOllos

unread,
Dec 23, 2020, 4:22:34 PM12/23/20
to Trac Users
This shouldn't be happening with Trac 1.4.2. There was no change in the allowed characters for milestones. I tested with Trac standalone and the HTML on the page is:

<a href="/proj-1.3/milestone/With%20whitespace">
Milestone:                 <em>With whitespace</em></a> 

The URL encoding in the error message might be a hint as to the problem. I think someone else may have raised this issue on the forum, but I can't locate it right now.

My best guess would be a plugin or webserver configuration causing the problem. Do you have any plugins installed such as SimpleMultiProject?

Ryan

Rob Hills

unread,
Dec 23, 2020, 9:11:40 PM12/23/20
to Trac Users
Hi Ryan, thanks for your reply.

I've since established that the problem is not just with Milestones.  Versions and Components, two other areas where we have spaces in names suffer the same problem.

Re plugins, I carried over the ones from our old installation that were supposedly compatible with 1.4.  I have:
  • TracAccountManager 0.6.dev0
  • TracTags 0.11
  • TracThemeEngine 2.2.4
  • TracXMLRPC 1.1.9
  • TracCrystalXTheme 1.1 (installed but not active as it is broken in Trac 1.4.2)
Maybe I should completely uninstall the theme-related ones since they're not in use currently anyway?

RjOllos

unread,
Dec 23, 2020, 9:16:04 PM12/23/20
to Trac Users
On Wednesday, December 23, 2020 at 6:11:40 PM UTC-8 rcp....@gmail.com wrote:
Hi Ryan, thanks for your reply.

I've since established that the problem is not just with Milestones.  Versions and Components, two other areas where we have spaces in names suffer the same problem.

Re plugins, I carried over the ones from our old installation that were supposedly compatible with 1.4.  I have:
  • TracAccountManager 0.6.dev0
  • TracTags 0.11
  • TracThemeEngine 2.2.4
  • TracXMLRPC 1.1.9
  • TracCrystalXTheme 1.1 (installed but not active as it is broken in Trac 1.4.2)
Maybe I should completely uninstall the theme-related ones since they're not in use currently anyway?

Worth a try. You could just disable TracThemeEngine and TracCrystalXTheme through the plugin admin page or directly editing the [components] section of trac.ini.

Rob Hills

unread,
Dec 24, 2020, 3:45:30 AM12/24/20
to Trac Users
OK, I tried disabling both plugins, still have the problem.  I've now also tried uninstalling both TracCrystalXTheme and TracThemeEngine and restarted my webserver (httpd).  Still the problem exists.  Trying to edit any element of the Ticket System that contains a space (in my case I have records in Components, Milestones, Resolutions and Versions that have one or more spaces in their Name field) triggers the "invalid ... name" error.

Does anybody with Trac 1.4.2 installed have a Milestone (or Component, or Resolution or Version!) with a space in its name.  If so, can you let me know what the "edit" URL looks like?  An example of a failing URL on my Trac instance is:

/admin/ticket/milestones/Release%20Edition%205.4

So, for a Milestone with the name "Release Edition 5.4", how should the Edit URL be encoded?

Jeff McKenna

unread,
Dec 24, 2020, 6:15:49 AM12/24/20
to trac-...@googlegroups.com
Hi Rob, here's an example milestone with spaces, using Trac 1.4.2 : https://ms4w.com/trac/milestone/4.1.0%20release

-jeff



--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/620113c8-c98f-41ef-990a-2a674b477ec7n%40googlegroups.com.

RjOllos

unread,
Dec 24, 2020, 10:45:11 PM12/24/20
to Trac Users
What web server are you running?

Do you have any custom templates in $env/templates? Those will also be shown on the About Trac page:

Screen Shot 2020-12-24 at 19.44.34.jpg 

Rob Hills

unread,
Dec 25, 2020, 10:50:23 AM12/25/20
to Trac Users
Thanks for that Jeff.  Unfortunately I can't see any difference between the way Milestone lists are rendered on your site and the way they are rendered on mine.

Rob Hills

unread,
Dec 25, 2020, 11:09:01 AM12/25/20
to Trac Users
Thanks again for your replies and suggestions.

There are no custom templates showing on my About Trac page.

I'm running on Apache 2.4.46 on Centos 7 (in cPanel).

RjOllos

unread,
Dec 25, 2020, 11:43:44 PM12/25/20
to Trac Users
On Wednesday, December 23, 2020 at 12:18:11 PM UTC-8 rcp....@gmail.com wrote:
Could you post a screen capture of the milestone page and a screen capture after navigation to a milestone fails to show the milestone? 

Rob Hills

unread,
Dec 26, 2020, 10:19:46 PM12/26/20
to Trac Users
Hi again Ryan,

Thanks for your perseverance!

Here are the screenshots, first my milestone list:
(Relative URL: /admin/ticket/milestones )
screenshot-trac-manage-milestones.png

Then, after I click on "Release Edition 5.2" (though same result from all of them):
(its relative URL is: /admin/ticket/milestones/Release%20Edition%205.2 )

screenshot-trac-edit-milestone.png

Note, I get the same result if I try and access milestones other ways, eg via the Roadmap page.

I've had a look at the data in my database (SQLite).  The Milestone names there are stored with spaces rather than the URL-encoded spaces (%20).  Is that how it should be?  I have tried experimenting with adding a new milestone record with a space in its name.  I can do that from the Admin Interface without any problem, but I still can't edit that new milestone!  However, I've just discovered that I can delete my newly added Milestone from the Milestone Admin list!  I don't want to try deleting an existing Milestone as there is data that I care about associated with those!

Rob Hills

unread,
Dec 26, 2020, 10:25:25 PM12/26/20
to Trac Users
Oh, and for the record, I've just tried adding a Milestone without spaces in its name (I added "Release_Edition_5.6") and after adding that, I was able to edit it without any problem.  So it's definitely the spaces that are the issue!

Noting that the database stores the records with spaces rather than the URL-encoding, presumable at some point in the "Edit" sequence, the URL-encoding is decoded back to normal ASCII.  Might I be able to get greater visibility of what's going on at that level by cranking up the logging?

RjOllos

unread,
Dec 27, 2020, 2:52:43 PM12/27/20
to Trac Users
On Saturday, December 26, 2020 at 7:25:25 PM UTC-8 rcp....@gmail.com wrote:
Oh, and for the record, I've just tried adding a Milestone without spaces in its name (I added "Release_Edition_5.6") and after adding that, I was able to edit it without any problem.  So it's definitely the spaces that are the issue!

Noting that the database stores the records with spaces rather than the URL-encoding, presumable at some point in the "Edit" sequence, the URL-encoding is decoded back to normal ASCII.  Might I be able to get greater visibility of what's going on at that level by cranking up the logging?

Yeah, good idea. The URL value should be decoded by the Trac front-end and stored as space-separated in the database. Here are some select excerpts from the log when navigating to "Release Edition 5.3" with TracStandalone as the webserver:

11:43:52 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/milestone/Release Edition 5.3'">
...
11:47:13 Trac[perm] DEBUG: DefaultPermissionPolicy allows user1 performing MILESTONE_VIEW on <Resource u'milestone:Release Edition 5.3'>
...
11:47:13 Trac[main] WARNING: [127.0.0.1] HTTPNotFound: 404 Not Found (File your_project_logo.png not found), <RequestWithSession "GET '/chrome/site/your_project_logo.png'">, referrer 'http://localhost:8001/proj-1.4/milestone/Release%20Edition%205.3'


At the moment I don't remember where the decoding occurs, but I'm pretty sure it's in the Request class:

Ryan

Rob Hills

unread,
Dec 28, 2020, 8:37:46 AM12/28/20
to Trac Users
Unfortunately the debug log doesn't seem to help much AFAICT.  No exceptions or errors seen.  Here is the log from when I click on a Milestone to edit it (some identifying details obfuscated)...
2020-12-28 10:00:57,746 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/milestone/Release%20Edition%205.3'">
2020-12-28 10:00:57,747 Trac[main] DEBUG: Chosen handler is <Component trac.ticket.roadmap.MilestoneModule>
2020-12-28 10:00:57,749 Trac[session] DEBUG: Retrieving session for ID u'rob'
2020-12-28 10:00:57,752 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_USER_ADMIN on None
2020-12-28 10:00:57,752 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing MILESTONE_VIEW on <Resource u'milestone:Release%20Edition%205.3'>
2020-12-28 10:00:57,752 Trac[chrome] DEBUG: Prepare chrome data for request
2020-12-28 10:00:57,754 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_CONFIG_ADMIN on None
2020-12-28 10:00:57,754 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/basics'>
2020-12-28 10:00:57,754 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/logging'>
2020-12-28 10:00:57,755 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing PERMISSION_GRANT on <Resource u'admin:general/perm'>
2020-12-28 10:00:57,755 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/plugin'>
2020-12-28 10:00:57,755 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/components'>
2020-12-28 10:00:57,755 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing MILESTONE_ADMIN on <Resource u'admin:ticket/milestones'>
2020-12-28 10:00:57,755 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/versions'>
2020-12-28 10:00:57,756 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/priority'>
2020-12-28 10:00:57,756 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/resolution'>
2020-12-28 10:00:57,756 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/severity'>
2020-12-28 10:00:57,756 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/type'>
2020-12-28 10:00:57,757 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing VERSIONCONTROL_ADMIN on <Resource u'admin:versioncontrol/repository'>
2020-12-28 10:00:57,757 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TAGS_ADMIN on None
2020-12-28 10:00:57,758 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing SEARCH_VIEW on None
2020-12-28 10:00:57,759 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ROADMAP_VIEW on None
2020-12-28 10:00:57,759 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_VIEW on <Resource 'ticket'>
2020-12-28 10:00:57,759 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing REPORT_VIEW on <Resource u'report:-1'>
2020-12-28 10:00:57,759 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_CREATE on None
2020-12-28 10:00:57,760 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TIMELINE_VIEW on <Resource 'timeline'>
2020-12-28 10:00:57,760 Trac[PyGIT] DEBUG: PyGIT.Storage instance for '/..../repos/git/wacg/wacg_tracker.git' is constructed
2020-12-28 10:00:57,761 Trac[PyGIT] DEBUG: requested weak PyGIT.Storage instance for '/..../repos/git/wacg/wacg_tracker.git'
2020-12-28 10:00:57,761 Trac[git_fs] DEBUG: disabled CachedRepository for '/..../repos/git/wacg/wacg_tracker.git'
2020-12-28 10:00:57,761 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing BROWSER_VIEW on <Resource u'repository, source:/'>
2020-12-28 10:00:57,761 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing WIKI_VIEW on <Resource u'wiki:WikiStart'>
2020-12-28 10:00:57,762 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing WIKI_VIEW on <Resource u'wiki:TracGuide'>
2020-12-28 10:00:57,762 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_VIEW_HOURS on None
2020-12-28 10:00:57,762 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TAGS_VIEW on None
2020-12-28 10:00:57,763 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing MILESTONE_CREATE on <Resource u'milestone:Release%20Edition%205.3'>
2020-12-28 10:00:57,769 Trac[main] DEBUG: Rendering response with template milestone_edit.html
2020-12-28 10:00:57,855 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/chrome/site/your_project_logo.png'">
2020-12-28 10:00:57,856 Trac[main] DEBUG: Chosen handler is <Component trac.web.chrome.Chrome>
2020-12-28 10:00:57,857 Trac[session] DEBUG: Retrieving session for ID u'rob'
2020-12-28 10:00:57,859 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_USER_ADMIN on None
2020-12-28 10:00:57,859 Trac[chrome] WARNING: File your_project_logo.png not found in any of ['/..../trac/venv/trac_project/htdocs']
2020-12-28 10:00:57,860 Trac[main] WARNING: [124.188.231.240] HTTPNotFound: 404 Not Found (File your_project_logo.png not found), <RequestWithSession "GET '/chrome/site/your_project_logo.png'">, referrer 'http://tracker.blah.thing.com.au/milestone/Release%20Edition%205.3'
2020-12-28 10:00:57,860 Trac[chrome] DEBUG: Prepare chrome data for request
2020-12-28 10:00:57,862 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_CONFIG_ADMIN on None
2020-12-28 10:00:57,862 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/basics'>
2020-12-28 10:00:57,862 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/logging'>
2020-12-28 10:00:57,862 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing PERMISSION_GRANT on <Resource u'admin:general/perm'>
2020-12-28 10:00:57,862 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TRAC_ADMIN on <Resource u'admin:general/plugin'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/components'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing MILESTONE_ADMIN on <Resource u'admin:ticket/milestones'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/versions'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/priority'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/resolution'>
2020-12-28 10:00:57,863 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/severity'>
2020-12-28 10:00:57,864 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_ADMIN on <Resource u'admin:ticket/type'>
2020-12-28 10:00:57,864 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing VERSIONCONTROL_ADMIN on <Resource u'admin:versioncontrol/repository'>
2020-12-28 10:00:57,864 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TAGS_ADMIN on None
2020-12-28 10:00:57,865 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing SEARCH_VIEW on None
2020-12-28 10:00:57,865 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ROADMAP_VIEW on None
2020-12-28 10:00:57,866 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_VIEW on <Resource 'ticket'>
2020-12-28 10:00:57,866 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing REPORT_VIEW on <Resource u'report:-1'>
2020-12-28 10:00:57,866 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_CREATE on None
2020-12-28 10:00:57,867 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TIMELINE_VIEW on <Resource 'timeline'>
2020-12-28 10:00:57,867 Trac[PyGIT] DEBUG: PyGIT.Storage instance for '/..../repos/git/wacg/wacg_tracker.git' is constructed
2020-12-28 10:00:57,867 Trac[PyGIT] DEBUG: requested weak PyGIT.Storage instance for '/..../repos/git/wacg/wacg_tracker.git'
2020-12-28 10:00:57,868 Trac[git_fs] DEBUG: disabled CachedRepository for '/..../repos/git/wacg/wacg_tracker.git'
2020-12-28 10:00:57,868 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing BROWSER_VIEW on <Resource u'repository, source:/'>
2020-12-28 10:00:57,868 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing WIKI_VIEW on <Resource u'wiki:WikiStart'>
2020-12-28 10:00:57,869 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing WIKI_VIEW on <Resource u'wiki:TracGuide'>
2020-12-28 10:00:57,869 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TICKET_VIEW_HOURS on None
2020-12-28 10:00:57,869 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing TAGS_VIEW on None
2020-12-28 10:00:57,897 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/chrome/common/trac.ico'">
2020-12-28 10:00:57,898 Trac[main] DEBUG: Chosen handler is <Component trac.web.chrome.Chrome>
2020-12-28 10:00:57,899 Trac[session] DEBUG: Retrieving session for ID u'rob'
2020-12-28 10:00:57,901 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_USER_ADMIN on None


I can't see anything in the above that helps me with this problem.

Rob Hills

unread,
Dec 28, 2020, 8:54:24 AM12/28/20
to Trac Users
Earlier on the log there are some references to some plugins not loading, eg this one:
2020-12-28 09:28:53,795 Trac[loader] DEBUG: Loading plugin "acct_mgr.opt.announcer.uid_chg" from "/..../trac/venv/lib/python2.7/site-packages"
2020-12-28 09:28:53,805 Trac[loader] DEBUG: Skipping "acct_mgr.opt.announcer.uid_chg = acct_mgr.opt.announcer.uid_chg [announcer]": DistributionNotFound: The 'TracAnnouncer; extra == "announcer"' distribution was not found and is required by the application

I haven't ever loaded or installed this plugin so I'm not sure why it's even being loaded, but maybe it's a core part of Trac?  If so, does it matter if they don't load?  Could one of these be behind my problem?

RjOllos

unread,
Dec 28, 2020, 11:06:46 PM12/28/20
to Trac Users
On Monday, December 28, 2020 at 5:37:46 AM UTC-8 rcp....@gmail.com wrote:
Unfortunately the debug log doesn't seem to help much AFAICT.  No exceptions or errors seen.  Here is the log from when I click on a Milestone to edit it (some identifying details obfuscated)...
2020-12-28 10:00:57,746 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/milestone/Release%20Edition%205.3'">
2020-12-28 10:00:57,747 Trac[main] DEBUG: Chosen handler is <Component trac.ticket.roadmap.MilestoneModule>
2020-12-28 10:00:57,749 Trac[session] DEBUG: Retrieving session for ID u'rob'
2020-12-28 10:00:57,752 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing ACCTMGR_USER_ADMIN on None
2020-12-28 10:00:57,752 Trac[perm] DEBUG: DefaultPermissionPolicy allows rob performing MILESTONE_VIEW on <Resource u'milestone:Release%20Edition%205.3'>

The resource id should have been decoded. Compare to the log I sent which has:

Dispatching <RequestWithSession "GET '/milestone/Release Edition 5.3'">
...
DefaultPermissionPolicy allows user1 performing MILESTONE_VIEW on <Resource u'milestone:Release Edition 5.3'>

I'll take a look at the codebase and see if I have any guesses as to the problem.

Ryan


RjOllos

unread,
Dec 28, 2020, 11:44:45 PM12/28/20
to Trac Users
On Friday, December 25, 2020 at 8:09:01 AM UTC-8 rcp....@gmail.com wrote:
Thanks again for your replies and suggestions.

There are no custom templates showing on my About Trac page.

I'm running on Apache 2.4.46 on Centos 7 (in cPanel).

Which module are you using?: mod_wsgi, mod_python, mod_fcgi, mod_cgi, or another?

This is the first time I've explored this detail, but it seems that the unquoting is done by the WSGI layer.

Is it possible you have a rewrite rule in Apache that is affecting this?

Ryan

RjOllos

unread,
Dec 29, 2020, 12:13:12 AM12/29/20
to Trac Users
On Saturday, December 26, 2020 at 7:19:46 PM UTC-8 rcp....@gmail.com wrote:
Hi again Ryan,

Thanks for your perseverance!

Thank you for your perseverance as well! I'm sure this is not the best user experience, but we will get to the bottom of this eventually and maybe we can find a way to make Trac better along the way.

Ryan 

Rob Hills

unread,
Dec 29, 2020, 12:50:42 AM12/29/20
to Trac Users
Hi again Ryan,

I am using mod_wsgi but because I am locked in to cPanel here, I have to use the one that cPanel permits in its framework.  I gather cPanel uses the [https://www.phusionpassenger.com/docs/tutorials/what_is_passenger/ Phusion Passenger] App server.  It was quite a process getting Trac to even work with this, I had to Google widely and knit together multiple tidbits of information!  Unfortunately this means that lots of the nuts and bolts (like the Apache configuration) are hidden from the user.

So, it's entirely possible I've mucked something up along the way to cause this issue.

My Trac instance web root has the following structure (the symlinks were necessitated by Passenger!):
  •  cgi-bin folder
  •  htdocs folder
  •  public folder (symlink to htdocs)
  • passenger_wsgi.py (symlink to cgi-bin/trac.wsgi)
The contents of my trac.wsgi (with a little obfuscation) had to be tweaked slightly from the one created by Trac and is as follows:
#!/<various-folders>/applications/trac/venv/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C)2008-2009 Edgewall Software
# Copyright (C) 2008 Noah Kantrowitz <email-address-removed>
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at https://trac.edgewall.org/log/.
#
# Author: Noah Kantrowitz <email-address-removed>
import sys, os
INTERP = "/<various-folders>/applications/trac/venv/bin/python"
#INTERP is present twice so that the new Python interpreter knows the actual executable path
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

def application(environ, start_request):
    if not 'trac.env_parent_dir' in environ:
        environ.setdefault('trac.env_path', '/<various-folders>/applications/trac/venv/trac_project')
    if 'PYTHON_EGG_CACHE' in environ:
        os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
    elif 'trac.env_path' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_path'], '.egg-cache')
    elif 'trac.env_parent_dir' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
    from trac.web.main import dispatch_request
    return dispatch_request(environ, start_request)


Maybe I need to put some debug logging in here?  If so, where/what would you suggest?

Cheers,

Rob Hills
Waikiki, Western Australia

Ryan Ollos

unread,
Dec 29, 2020, 1:39:51 AM12/29/20
to Trac Users
With TracStandalone I pprint'ed the environ dict at the start of dispatch_request:

{'CONTENT_TYPE': 'text/plain',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, br',
 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9,fr-FR;q=0.8,fr;q=0.7',
 'HTTP_AUTHORIZATION': 'Digest username="user1", realm="trac", nonce="854d06777afa9b9a5b0243a3a7453d5e", uri="/proj-1.4/milestone/Release%20Edition%205.3", response="b90c6b243cc22c34aef5ce336e9865e3", qop=auth, nc=00000028, cnonce="6ddef167d2ec8331"',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'trac_form_token=6fedb0898635ff6cb18e7231; trac_auth=db9c3ee6304876204f470c8217fdba24',
 'HTTP_HOST': 'localhost:8001',
 'HTTP_REFERER': 'http://localhost:8001/proj-1.4/roadmap',
 'HTTP_SEC_FETCH_DEST': 'document',
 'HTTP_SEC_FETCH_MODE': 'navigate',
 'HTTP_SEC_FETCH_SITE': 'same-origin',
 'HTTP_SEC_FETCH_USER': '?1',
 'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
 'PATH_INFO': '/proj-1.4/milestone/Release Edition 5.3',
 'QUERY_STRING': '', 

But I don't suppose the output would be captured anywhere visible if you put at the start of the application function?:

import pprint
pprint.pprint(environ)

But maybe Passenger would capture it in a log? Or you could open a file and output to a file?

Ryan

Jun Omae

unread,
Dec 29, 2020, 2:17:41 AM12/29/20
to trac-...@googlegroups.com
On Tue, Dec 29, 2020 at 3:39 PM Ryan Ollos <rjo...@gmail.com> wrote:
>
> On Mon, Dec 28, 2020 at 9:50 PM Rob Hills <rcp....@gmail.com> wrote:
>>
>> Hi again Ryan,
>>
>> I am using mod_wsgi but because I am locked in to cPanel here, I have to use the one that cPanel permits in its framework. I gather cPanel uses the [https://www.phusionpassenger.com/docs/tutorials/what_is_passenger/ Phusion Passenger] App server. It was quite a process getting Trac to even work with this, I had to Google widely and knit together multiple tidbits of information! Unfortunately this means that lots of the nuts and bolts (like the Apache configuration) are hidden from the user.
>>
>> So, it's entirely possible I've mucked something up along the way to cause this issue.
>>
>> My Trac instance web root has the following structure (the symlinks were necessitated by Passenger!):
>>
>> cgi-bin folder
>> htdocs folder
>> public folder (symlink to htdocs)
>> passenger_wsgi.py (symlink to cgi-bin/trac.wsgi)
> ...
> But maybe Passenger would capture it in a log? Or you could open a file and output to a file?
>
> Ryan

The issue has been reported at
https://github.com/phusion/passenger/issues/1828, however it is not
fixed yet.

--
Jun Omae <jun...@gmail.com> (大前 潤)

RjOllos

unread,
Dec 29, 2020, 2:22:21 AM12/29/20
to Trac Users
Good find!

Would it be a sufficient workaround to modify the environ dict?

import urllib
environ['PATH_INFO'] = urllib.unquote(environ['PATH_INFO'])

I wonder why the issue wasn't seen before upgrading from 0.12.x.

Ryan

Jun Omae

unread,
Dec 29, 2020, 2:58:23 AM12/29/20
to trac-...@googlegroups.com
Yeah. I think that's enough to work around for the issue.

Rob Hills

unread,
Dec 29, 2020, 3:05:28 AM12/29/20
to Trac Users
Thank you Ryan and Jun!  That workaround in my trac.wsgi has fixed the problem.  To close off the loop for others following, this is the change I made to my trac.wsgi:

Original application(..) method:
def application(environ, start_request):
    if not 'trac.env_parent_dir' in environ:
        environ.setdefault('trac.env_path', '/home/rhills/applications/trac/venv/trac_project')

    if 'PYTHON_EGG_CACHE' in environ:
        os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
    elif 'trac.env_path' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_path'], '.egg-cache')
    elif 'trac.env_parent_dir' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
    from trac.web.main import dispatch_request
    return dispatch_request(environ, start_request)


New (working) application(..) method:
def application(environ, start_request):

    # By Rob Hills: Workaround for Passenger bug (https://github.com/phusion/passenger/issues/1828) that means spaces in URLs aren't properly decoded:
    # see also https://groups.google.com/g/trac-users/c/Jm9JbiG5BJg for detailed discussion
    import urllib
    environ['PATH_INFO'] = urllib.unquote(environ['PATH_INFO'])
    # End workaround.


    if not 'trac.env_parent_dir' in environ:
        environ.setdefault('trac.env_path', '/home/rhills/applications/trac/venv/trac_project')

    if 'PYTHON_EGG_CACHE' in environ:
        os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
    elif 'trac.env_path' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_path'], '.egg-cache')
    elif 'trac.env_parent_dir' in environ:
        os.environ['PYTHON_EGG_CACHE'] = \
            os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
    from trac.web.main import dispatch_request
    return dispatch_request(environ, start_request)



Many thanks again for all your help,

Rob Hills
Waikiki, Western Australia

Rob Hills

unread,
Dec 29, 2020, 3:08:44 AM12/29/20
to Trac Users
Ryan, the issue wasn't seen before upgrading because I had moved from one server to another before upgrading.  My previous server environment was completely different, and much more Python-centric at the time.  For the record I was on a server run by Webfaction but since they have been bought out their parent company announced they were withdrawing support for Python with three months notice!


Cheers,
Rob Hills
Waikiki, Western Australia

RjOllos

unread,
Dec 29, 2020, 3:13:50 AM12/29/20
to Trac Users
On Tuesday, December 29, 2020 at 12:08:44 AM UTC-8 rcp....@gmail.com wrote:
Ryan, the issue wasn't seen before upgrading because I had moved from one server to another before upgrading.  My previous server environment was completely different, and much more Python-centric at the time.  For the record I was on a server run by Webfaction but since they have been bought out their parent company announced they were withdrawing support for Python with three months notice!

Ah, thanks for closing that loop. Always nice to find there's a logical explanation.

Ryan
Reply all
Reply to author
Forward
0 new messages