Defect #13133

Unable to create or update a custom date field.

Added by Cheyenne Wills over 6 years ago. Updated over 6 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Custom fields
Target version:-
Resolution: Affected version:

Description

About your application's environment
Ruby version              1.8.7 (x86_64-linux)
RubyGems version          1.8.24
Rack version              1.1.3
Rails version             2.3.15
Active Record version     2.3.15
Active Resource version   2.3.15
Action Mailer version     2.3.15
Active Support version    2.3.15
Application root          /var/lib/redmine
Environment               production
Database adapter          mysql
Database schema version   20120301153455

About your Redmine plugins
Project Subscription                    0.0.1b
Redmine plugin views revisions plugin   0.0.1
Extra query operators plugin            0.1.1
Redmine Groups plugin                   1.0.0
Mylyn Connector plugin                  2.7.6.stable
Smart issues sort plugin                0.3.1
Redmine Better Gantt Chart plugin       0.6.5
Issue query operators plugin            0.0.2

History

#1 Updated by Cheyenne Wills over 6 years ago

(oops... hit enter too fast).

The following fails on Redmine 1.4.5 (we upgraded from 1.3.2 where this worked.)


#!/usr/bin/python
import httplib
import sys
import json

def openissue(data):

    mykey = "dsds....adsadasdasdasdsadsadsadasdasdasdasda" 
    jsondata = json.dumps(data)
    # Log into Redmine
    conn = httplib.HTTPSConnection("oursite.internal.com")

    headers = { "Content-Type" : "application/json",
                "X-Redmine-API-Key" : mykey
              }
    conn.request("POST", "/redmine/issues.json", jsondata, headers)

    response = conn.getresponse()

data = {
   "issue": {
      "project_id":"testproject",
      "tracker":"Bug",
      "subject": "test",
      "custom_fields": [ {"id":7,"value":"2013-01-01"}]
   }
}

openissue(data)

In tracing the error, I am getting "is not a valid date"

The Redmine log has the following (w/minor edits to remove ip addresses and api keys)

Feb 11 13:03:01 penguint Redmine[5889]: Processing IssuesController#create to json (for 1.1.1.1 at 2013-02-11 13:03:01) [POST]
Feb 11 13:03:01 penguint Redmine[5889]: Parameters: {"action"=>"create", "format"=>"json", "controller"=>"issues", "issue"=>{"custom_fields"=>[{"id"=>7, "name"=>"datefield", "value"=>Wed, 02 Jan 2013}], "tracker"=>"Bug", "subject"=>"test", "project_id"=>"testproject"}}
Feb 11 13:03:01 penguint Redmine[5889]: SQL (0.4ms)   SELECT max(`settings`.updated_on) AS max_updated_on FROM `settings`
Feb 11 13:03:01 penguint Redmine[5889]: Token Load (0.3ms)   SELECT * FROM `tokens` WHERE (`tokens`.`value` = '...apikey....' AND `tokens`.`action` = 'api') LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: User Load (0.3ms)   SELECT * FROM `users` WHERE (`users`.`id` = 4) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) ) 
Feb 11 13:03:01 penguint Redmine[5889]: Project Load (0.3ms)   SELECT * FROM `projects` WHERE (`projects`.`identifier` = 'testproject') LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: EnabledModule Load (0.3ms)   SELECT name FROM `enabled_modules` WHERE (`enabled_modules`.project_id = 1)
Feb 11 13:03:01 penguint Redmine[5889]: IssueStatus Load (0.3ms)   SELECT * FROM `issue_statuses` WHERE (is_default=1) LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: IssueStatus Load (0.3ms)   SELECT * FROM `issue_statuses` WHERE (`issue_statuses`.`id` = 0)
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `issue_statuses` WHERE (is_default=1) LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: IssuePriority Load (0.3ms)   SELECT * FROM `enumerations` WHERE (`enumerations`.`id` = 0) AND ( (`enumerations`.`type` = 'IssuePriority' ) ) ORDER BY enumerations.position ASC
Feb 11 13:03:01 penguint Redmine[5889]: IssuePriority Load (0.3ms)   SELECT * FROM `enumerations` WHERE (`enumerations`.`is_default` = 1) AND ( (`enumerations`.`type` = 'IssuePriority' ) ) ORDER BY enumerations.position ASC LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: SQL (0.3ms)   BEGIN
Feb 11 13:03:01 penguint Redmine[5889]: SQL (0.2ms)   COMMIT
Feb 11 13:03:01 penguint Redmine[5889]: Project Load (0.3ms)   SELECT * FROM `projects` WHERE (`projects`.`id` = 0)
Feb 11 13:03:01 penguint Redmine[5889]: Project Load (0.3ms)   SELECT * FROM `projects` WHERE (`projects`.`id` = 1)
Feb 11 13:03:01 penguint Redmine[5889]: Tracker Load (0.3ms)   SELECT * FROM `trackers` WHERE (`trackers`.`id` = 0)
Feb 11 13:03:01 penguint Redmine[5889]: Tracker Load (0.3ms)   SELECT * FROM `trackers` INNER JOIN `projects_trackers` ON `trackers`.id = `projects_trackers`.tracker_id WHERE (`projects_trackers`.project_id = 1 ) ORDER BY trackers.position LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `issue_statuses` WHERE (is_default=1) LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: Role Load (0.3ms)   SELECT * FROM `roles`
Feb 11 13:03:01 penguint Redmine[5889]: Workflow Load (0.3ms)   SELECT * FROM `workflows` WHERE (`workflows`.old_status_id = 1 AND (role_id IN (1,2,3,4,5) AND tracker_id = 1 AND ((author = 0 AND assignee = 0) OR author = 1)))
Feb 11 13:03:01 penguint Redmine[5889]: IssueStatus Load (0.3ms)   SELECT * FROM `issue_statuses` WHERE (`issue_statuses`.`id` IN (6,5,4,3,2))
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `projects` WHERE (`projects`.`id` = 1)
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT name FROM `enabled_modules` WHERE (`enabled_modules`.project_id = 1)
Feb 11 13:03:01 penguint Redmine[5889]: IssueCustomField Load (0.3ms)   SELECT * FROM `custom_fields` WHERE (is_for_all=1) AND ( (`custom_fields`.`type` = 'IssueCustomField' ) ) ORDER BY position
Feb 11 13:03:01 penguint Redmine[5889]: IssueCustomField Load (0.3ms)   SELECT * FROM `custom_fields` INNER JOIN `custom_fields_projects` ON `custom_fields`.id = `custom_fields_projects`.custom_field_id WHERE (`custom_fields_projects`.project_id = 1 ) AND ( (`custom_fields`.`type` = 'IssueCustomField' ) ) ORDER BY custom_fields.position
Feb 11 13:03:01 penguint Redmine[5889]: IssueCustomField Load (0.3ms)   SELECT `custom_fields`.* FROM `custom_fields` INNER JOIN `custom_fields_trackers` ON `custom_fields`.id = `custom_fields_trackers`.custom_field_id WHERE (`custom_fields_trackers`.tracker_id = 1 ) AND ( (`custom_fields`.`type` = 'IssueCustomField' ) )
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `issue_statuses` WHERE (is_default=1) LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `roles`
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `workflows` WHERE (`workflows`.old_status_id = 1 AND (role_id IN (1,2,3,4,5) AND tracker_id = 1 AND ((author = 0 AND assignee = 0) OR author = 1)))
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `issue_statuses` WHERE (`issue_statuses`.`id` IN (6,5,4,3,2))
Feb 11 13:03:01 penguint Redmine[5889]: CACHE (0.0ms)   SELECT * FROM `issue_statuses` WHERE (is_default=1) LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: User Load (0.9ms)   SELECT `users`.* FROM `users` INNER JOIN `members` ON `users`.id = `members`.user_id WHERE ((`members`.project_id = 1) AND ((users.type='User' AND users.status=1))) AND ( (`users`.`type` = 'User' OR `users`.`type` = 'AnonymousUser' ) )
Feb 11 13:03:01 penguint Redmine[5889]: SQL (0.2ms)   BEGIN
Feb 11 13:03:01 penguint Redmine[5889]: Issue Load (0.5ms)   SELECT * FROM `issues` WHERE ((issues.id != NULL) AND ((issues.`lft` <= NULL AND issues.`rgt` >= NULL) AND (`issues`.`root_id` IS NULL))) ORDER BY issues.`lft`
Feb 11 13:03:01 penguint Redmine[5889]: Tracker Load (0.4ms)   SELECT `trackers`.id FROM `trackers` INNER JOIN `projects_trackers` ON `trackers`.id = `projects_trackers`.tracker_id WHERE (`trackers`.`id` = 1) AND (`projects_trackers`.project_id = 1 ) ORDER BY trackers.position LIMIT 1
Feb 11 13:03:01 penguint Redmine[5889]: SQL (0.3ms)   ROLLBACK
Feb 11 13:03:01 penguint Redmine[5889]: Rendering common/error_messages.api (unprocessable_entity)
Feb 11 13:03:01 penguint Redmine[5889]: Completed in 71ms (View: 11, DB: 8) | 422 Unprocessable Entity [https://internal.website.internal/redmine/issues.json]

There is a message out in the help forum where someone else has/had the same problem ( http://www.redmine.org/boards/2/topics/32551 ).

I created a real ugly patch to fix it, I removed the regular expression test in app/models/custom_field.rb, and I also added a little bit of code to lib/redmine/custom_field_format.rb to test to see if the format type is 'date' before doing the ?empty test.

#2 Updated by Toshi MARUYAMA over 6 years ago

  • Category set to Custom fields

Also available in: Atom PDF