Terry's picture

I am using the Tracks Turnkey appliance, version 15.1.

Tracks allows tagging of action items and searching for those tags.  The 'starred' tag is built in and clicking on Starred in the top menu bar correctly returns a web page containing starred items from http://$TRACKSSERVER/todos/tag/starred.

Tracks also supports feeds for reporting task status as text or iCal objects.  The server provides constructed URLs for accessing these feeds.  Viewing the text feed for starred items uses the URL http://$TRACKSSERVER/todos.txt?tag=starred&token=$TRACKSTOKEN

However, trying to view this feed results in an error message.  The Tracks log shows the following in response to the request:

I, [2019-01-23T14:50:08.116570 #20719]  INFO -- : Started GET "/todos.txt?tag=starred&token=$TRACKSTOKEN" for $WEBCLIENT at 2019-01-23 14:50:08 -0500
I, [2019-01-23T14:50:08.119116 #20719]  INFO -- : Processing by TodosController#index as TEXT
I, [2019-01-23T14:50:08.119525 #20719]  INFO -- :   Parameters: {"tag"=>"starred", "token"=>"$TRACKSTOKEN"}
E, [2019-01-23T14:50:08.139435 #20719] ERROR -- : Mysql2::Error: Unknown column 'taggings.tag_id' in 'where clause': SELECT `todos`.* FROM `todos` INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id WHERE `todos`.`user_id` = 2 AND `todos`.`state` = 'active' AND (NOT(todos.state = 'project_hidden' OR (c_hidden.state = 'hidden' AND (todos.state = 'active' OR todos.state = 'deferred' OR todos.state = 'pending')))) AND (taggings.tag_id = 4)  ORDER BY todos.due IS NULL, todos.due ASC, todos.created_at ASC
I, [2019-01-23T14:50:08.140341 #20719]  INFO -- :   Rendered contexts/_context.text.erb (2.0ms)
I, [2019-01-23T14:50:08.140791 #20719]  INFO -- :   Rendered todos/index.text.erb (3.7ms)
I, [2019-01-23T14:50:08.141048 #20719]  INFO -- : Completed 500 Internal Server Error in 21ms (ActiveRecord: 2.5ms)
F, [2019-01-23T14:50:08.142705 #20719] FATAL -- : 
ActionView::Template::Error (Mysql2::Error: Unknown column 'taggings.tag_id' in 'where clause': SELECT `todos`.* FROM `todos` INNER JOIN contexts c_hidden ON c_hidden.id = todos.context_id WHERE `todos`.`user_id` = 2 AND `todos`.`state` = 'active' AND (NOT(todos.state = 'project_hidden' OR (c_hidden.state = 'hidden' AND (todos.state = 'active' OR todos.state = 'deferred' OR todos.state = 'pending')))) AND (taggings.tag_id = 4)  ORDER BY todos.due IS NULL, todos.due ASC, todos.created_at ASC):
    1: <%
    2:   todos_in_context = not_done_todos.select { |t| t.context_id == context.id }
    3:   if todos_in_context.length > 0
    4: -%> <%= context.name.upcase %>:
    5: <%= render :partial => "todos/todo", :collection => todos_in_context -%>
  app/views/contexts/_context.text.erb:2:in `_app_views_contexts__context_text_erb__515968339662070635_47432019401520'
  app/views/todos/index.text.erb:1:in `_app_views_todos_index_text_erb__2862269700048351187_47432024765020'
  app/controllers/todos_controller.rb:48:in `block (2 levels) in index'
  app/controllers/todos_controller.rb:29:in `index'

The taggings table does exist in the Tracks production database, and there is a tag_id field.  The constructed SQL statement doesn't reference this correctly.  It requires the following clause:

INNER JOIN taggings ON taggings.taggable_id  = todos.id

1. does anyone else have this problem?

2. could the bad SQL creation be due to a version issue with a gem?  I've gone through the source, but I'm not familiar with Ruby and it isn't clear to me how the SQL statements are templated and created.

Jeremy Davis's picture

I know very little about Rails myself and if the table and column exists, then I would assume that it's a bug in Tracks (or one of it's dependencies). FWIW we install the "latest" stable release of 2.3.0 (released way back in 2015). AFAIK no one else has reported this (but that doesn't always mean anything...)

Having a quick check of the Tracks "issues" I did find one that appears to match your experience. It was lodged way back in 2015, remains open and had only one response (confirming that someone else also got it too).

So that pretty much confirms that it's a Tracks bug IMO. Although it could be an incompatibility between the code and the version of Rails we're using? (Seems a bit unlikely as others reported it; but perhaps). Unfortunately, I have no idea on the best approach from here.

AFAIK over the last few years, Tracks has been in something of a limbo state. The core dev noted last year that he hasn't had much time and energy to devote to development and maintenance, but that he hasn't completely abandoned it. Having a closer looks, I see that there is actually a 2.3 branch which has some newer commits (most recent Aug 2016) so that may actually be a better place for us to be installing from? It may even have addressed this bug (although considering the issue is still open, perhaps not...)?

Having said that, I can see that the master branch (v2.4dev perhaps?) does appear to be relatively active of late, so perhaps that's worthy of a try? Although I note that the upgrade docs note:

WARNING: 2.4devel is a development tree of Tracks and may (will?) contain bugs that might destroy your data! It is not recommended to upgrade to 2.4devel unless you know what you are doing.

(Hence why we don't pre-install that by default).

Whilst I don't have much knowledge or experience with Ruby as a programming language or Rails as a platform in production, I do have a bit of experience updating Rails apps. IMO it's a PITA! If you care to give that a go, then I'd suggest having a look at their mailing list/forums. I reckon that they're probably the best ones to assist with that, so it might be worth posting there? (FWIW a quick browse there confirms the relatively recent increase in Tracks dev activity).

When I get a chance, I might investigate our next release using that (what appears to be a) maintenance branch, but if you try it, any feedback you have would be warmly welcomed. If you instead have a go at updating to the master branch, you may be better served installing that on our Rails appliance?

Whilst I can't currently provide much more than that, please feel free to post back with further questions if you need to understand the TurnKey environment more/better. Also I'd really love to hear how things go whichever path you take as that will assist us to make future releases of our appliance better for everyone!

Good luck!

Add new comment