Closed dreed47 closed 10 years ago
Funny I was just doing some testing and noticed the same problem. The error happens when you have have a custom field defined for the project, but the issue doesn't have a value assigned. I should have a fix committed shortly. I think I just need to drop the field from the update function in order for the API to ignore it.
Fixed in b48a7cd. I'm not sure how it handles when the custom field is set to required, and no value is specified. I'll give that a test when I have time.
I just remembered that drag and drop used a different function to update the custom fields. da2ea8f might be the fix you need.
I pulled your latest code and retested and I still get this error.
If you get time, would you mind running the following code in a javascript console, and post back the result.
JSON.stringify(Kanban.GetStoryByFieldValue("ID", 241).StorySource.custom_fields)
Replace 241 with the ID of the issue you are dropping. This should show me what the custom_fields looks like. It might give me a hint on what the problem is.
Are you able to edit and save the changes normally?
Also, just a reminder, that being javascript, the files are cached, so you might double check that its running on the latest locally.
"[{"field":{"id":"5","name":"Code Patch Needed"},"value":"Yes"},{"field":{"id":"4","name":"Environment"},"value":"Dev"},{"field":{"id":"6","name":"Filter Field"},"value":null},{"field":{"id":"7","name":"Grouping"},"value":"desktop - feature"}]"
BTW, thanks for being so responsive. Sorry to flood you with issues but I'm trying to assess whether this tool will work for my employer. And what you have is excellent work and is fairly close to what we need.
Glad I could help. I'm trying to get the system as functional for my company as well.
Could you verify the following in the JS console for me.
JSON.stringify(Kanban.GetStoryByFieldValue("ID", 241).StorySource.custom_fields)
That should return what you just sent me.
Then run this:
Mantis.RemoveNullCustomFieldsFromIssue(Kanban.GetStoryByFieldValue("ID", 241).StorySource)
Shouldn't return anything.
Then run this one again:
JSON.stringify(Kanban.GetStoryByFieldValue("ID", 241).StorySource.custom_fields)
The result should look like:
"[{"field":{"id":"5","name":"Code Patch Needed"},"value":"Yes"},{"field":{"id":"4","name":"Environment"},"value":"Dev"},{"field":{"id":"7","name":"Grouping"},"value":"desktop - feature"}]"
This is verifying that the "Filter Field" custom field is being removed from the custom_fields array since it has a null value. This way it doesn't get posted in the soap call to the server.
I've had no luck figuring this one out. Can you send me your custom field types, sample default values, and if they are required or not.
I've tried several scenarios on my side with no luck recreating the issue.
see attached. none of the fields are required
I removed the code patch field as we were no longer using it. I suspect the issue is with the Environment field as editing works if I have ONLY the filter field and grouping fields but doesn't work when I add Environment field. This is the settings page for that field.
Thanks for doing that digging. I"m sure that will give me what I need to replicate the problem on my end and create a fix. I"ll try to get to it sometime this evening.
Debugging the mantisConnect side of this issue I see the error is thrown in mci_issue_set_custom_fields() function. I can see it's trying to loop thru the custom fields array and dies on the first time thru because the fields are enclosed in an object. The php error is "Undefined index: field" because the first item in the array is an object. I'm trygin to see in the client code where this is being created.
Sorry for the slow response on this one. I"m leaving for vacation Friday, and I'm trying to wrap up several things between now and then.
Yeah looks like there is an extra array object in the middle. I'll check out the soap code that pulls the object, and see if its adding that extra layer. I modified it from the original source because of some bugs I found in it. I may have broke other things while fixing the other bugs.
yeah, doing an array_pop($p_issue['custom_fields']); on the PHP side gets this to work. Obviously a hack but shows that thats the issue.
Okay I've done a bit of JS debugging, and here is what the soap library is sending to the php script.
<custom_fields><Object><field><id>2</id><name>ScrumBucket</name></field><value>Design</value></Object><Object><field><id>3</id><name>Test</name></field><value></value></Object></custom_fields>
What version of Mantis are you running?
In soapclient.js, you can set a break point on line 178, and then run parameters.toXml() in the console to see the xml that is being sent to mantisconnect.
It should look similar to mine.
1.2.10 but I've tried the 1.2.12 version of the mantisconnect API code and it still gets the same error
could it be related to this code in mantis.js?
Don't think so. That code is only called if the "custom_fields" field doesn't exist on the object.
In your case, the object already has that field defined, so it shouldn't be called at all. You could set a break-point to be sure.
The primary function of that bit of code is when an issue is first getting assigned a custom field value, the issue object doesn't contain the custom_fields.
You could run this in a JS debugger to see how it creates the objects.
eval({"custom_fields":[{"field": {"id": "1", "name":"Test"}, "value":"myvalue"},{"field": {"id": "2", "name":"Test2"}, "value":"myvalue"}]})
The weird part is that what you and I are sending to Mantis in the soap request is the same. But our instance of mantis are interpreting them differently. I get no errors, and the field are able to be updated.
Can you throw a debug statement in your mc_issue_api.php file in function mc_issue_update() to dump the custom_fields variable right before it calls mci_issue_set_custom_fields()
I added the following line right above your arrow.
print_r($p_issue); exit;
This code without the two lines above produces no errors.
While debugging ajax call I see the responseText is:
Array
(
[id] => 241
[view_state] => Array
(
[id] => 10
[name] => public
)
[project] => Array
(
[id] => 6
[name] => 3rd Party Finance System
)
[category] => Apollo Browser
[priority] => Array
(
[id] => 30
[name] => normal
)
[severity] => Array
(
[id] => 50
[name] => minor
)
[status] => Array
(
[id] => 20
[name] => feedback
)
[reporter] => Array
(
[id] => 5
[name] => cgaspard
[real_name] =>
[email] =>
)
[summary] => 3rd Party Payment Tracking
[reproducibility] => Array
(
[id] => 70
[name] => have not tried
)
[date_submitted] => 2012-12-04T15:30:00-06:00
[sponsorship_total] => 0
[handler] => Array
(
[id] => 5
[name] => cgaspard
[real_name] =>
[email] =>
)
[projection] => Array
(
[id] => 10
[name] => none
)
[eta] => Array
(
[id] => 10
[name] => none
)
[resolution] => Array
(
[id] => 20
[name] => fixed
)
[description] => desc
[attachments] =>
[custom_fields] => Array
(
[Object] => Array
(
[field] => Array
(
[id] => 2
[name] => ScrumBucket
)
[value] => Design
)
)
[tags] =>
)
what version of mantis are you using? I see a difference in what I sent earlier
1.2.11
Here is what mci_issue_set_custom_fields looks like in my version:
function mci_issue_set_custom_fields( $p_issue_id, &$p_custom_fields, $p_log_insert ) {
# set custom field values on the submitted issue
if( isset( $p_custom_fields ) && is_array( $p_custom_fields ) ) {
foreach( $p_custom_fields as $t_custom_field ) {
# get custom field id from object ref
$t_custom_field_id = mci_get_custom_field_id_from_objectref( $t_custom_field['field'] );
if( $t_custom_field_id == 0 ) {
return new soap_fault( 'Client', '', 'Custom field ' . $t_custom_field['field']['name'] . ' not found.' );
}
# skip if current user doesn't have login access.
if( !custom_field_has_write_access( $t_custom_field_id, $p_issue_id ) ) {
continue;
}
$t_value = $t_custom_field['value'];
if( !custom_field_validate( $t_custom_field_id, $t_value ) ) {
return new soap_fault( 'Client', '', 'Invalid custom field value for field id ' . $t_custom_field_id . ' .');
}
if( !custom_field_set_value( $t_custom_field_id, $p_issue_id, $t_value, $p_log_insert ) ) {
return new soap_fault( 'Server', '', 'Unable to set custom field value for field id ' . $t_custom_field_id . ' to issue ' . $p_issue_id. ' .' );
}
}
}
}
Mine looks like that too. Notice the extra level in my dump.
Yeah I see that. What version of PHP are you running?
Here is my output of php -v
PHP 5.3.3-7+squeeze14 with Suhosin-Patch (cli) (built: Aug 6 2012 14:18:06) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
Could be the soap engine is different in our versions.
PHP 5.2.10 we cant go to 5.3 just yet due to some incompatibility issues with some of our sites
I cant recreate the problem with 5.3.6 or 5.2.17. This is a tough one I could see us maybe leaving the mantisconnect hack in until I figure this out (as long as everything else works). I think the biggest roadblock for us deploying this is the IE compatibility issue.
Yeah I've done a bit of research on the errors in the JS, and it shouldn't be too hard for me to correct. I'm also concerned about the styling since I've used mostly css 3.
What version of IE are you using so I can target that one for compatibility?
IE8 is corp standard. Will be moving to IE9 but wont be for at least 6-8 months at the earliest
I do have the same issue in Google Chrome 25 (latest one). PHP version is:
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Just curious if you guys have tried latest to see if the drag and drop issues is fixed for you? I haven't been able to recreate this issue myself. I use Chrome 33 and IE 11 for testing right now, and both seem to handle the drag and drop perfectly.
I don't think I want to try and support browsers that are too old. Since I don't have a ton of time for testing backward compatibility.
works fine now
Thanks for checking. Going to close this one out.
I'm seeing this error with the latest version of Mantis (1.2.19) and MantisKanban (latest commit 595e5eb17b). Using Chrome Version 42.0.2311.135 (64-bit). Anything I can do about it?
I haven't been able to recreate the error, so I don't have a clue how to fix it.
Do you have any debug information from Chrome? Any errors in the chrome error log?
Yes. There are errors:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. index.js:361 SelectProject() called. kanban.js:168 Uncaught TypeError: Cannot read property 'Element' of nullKanban.AddGlowToRelatedStories @ kanban.js:168onmouseover @ (index):1 kanban.js:177 Uncaught TypeError: Cannot read property 'Element' of nullKanban.RemoveGlowToRelatedStories @ kanban.js:177onmouseout @ (index):1 kanban.js:250 DragStart1 kanban.js:255 DragStart2 kanban.js:259 DragEnd1 kanban.js:262 DragEnd1 soapclient.js:197 POST http://mantisdomainname.com/api/soap/mantisconnect.php 500 (Internal Server Error)SOAPClient._sendSoapRequest @ soapclient.js:197SOAPClient._loadWsdl @ soapclient.js:139SOAPClient.invoke @ soapclient.js:125Mantis.IssueUpdate @ mantis.js:626UpdateListForCanbanStory @ kanban.js:426Drop @ kanban.js:301 kanban.js:336 UpdateKanbanStoryComplete Error: Error Type: SYSTEM NOTICE, Error Description: Undefined index: field
Thanks, John
After a bit more testing, I can also confirm that the error happens whether you are using the default states or add a custom ScrumBucket field to map stories into custom buckets. Let me know if you need more info. I'd actually be willing to do a join.me with you if it would help to get this resolved.
I currently have 3 custom fields (Code Review Status [list], Environment [list], and Iteration [numeric]).
Do you have parent / child relationships between the issues you are working with? I ask because the code that is erroring for you is related to that. The Kanban highlights parent and child issues when it detects them.
Grabbed a fresh error log:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/. index.js:361 SelectProject() called. index.js:361 SelectProject() called. index.js:499 Done Loading 68 kanban.js:250 DragStart1 kanban.js:255 DragStart2 kanban.js:259 DragEnd1 kanban.js:262 DragEnd1 soapclient.js:197 POST http://bugs.madakethealth.com/api/soap/mantisconnect.php 500 (Internal Server Error)SOAPClient._sendSoapRequest @ soapclient.js:197SOAPClient._loadWsdl @ soapclient.js:139SOAPClient.invoke @ soapclient.js:125Mantis.IssueUpdate @ mantis.js:626UpdateListForCanbanStory @ kanban.js:426Drop @ kanban.js:301 kanban.js:336 UpdateKanbanStoryComplete Error: Error Type: SYSTEM NOTICE, Error Description: Undefined index: field
These are the tickets currently within the view that exhibits this error: 1572 - no relationships 1571 - no relationships 1538 - parent of 1543 1573 - related to 1543 1561 - child of 1552 (completed and not in this filtered view) 1567 - no relationships 1568 - no relationships 1541 - no relationships 1539 - no relationships 1540 - no relationships 1581 - no relationships
Perhaps that relationship to the item not in this view is to blame, since it cannot highlight an element that isn't in the DOM? Does this code check to see if the element exists before trying to highlight it?
Shall I assume that having these kinds of relationships across our tickets is unsupported by MantisKanban?
Is the relationships between issues on separate projects? That is most likely the problem. Haven’t had a chance to really get in and debug the scenario, but I think that is probably it.
Corey On May 15, 2015 at 11:40:15 AM, John Rotondo (notifications@github.com) wrote:
Shall I assume that having these kinds of relationships across our tickets is unsupported by MantisKanban?
— Reply to this email directly or view it on GitHub.
According to Mantis, they are set to the same project, unfortunately.
When dragging an issue from one column to another I get the following error. I suspect it might have something to do with custom fields I have
Error Updating: Error: Error Type: SYSTEM NOTICE, Error Description: Undefined index: field, Stack Trace: mc_api.php L160 mc_error_handler() mc_issue_api.php L836 mci_issue_set_custom_fields() nusoap.php L4087 mc_issue_update() nusoap.php L4087 call_user_func_array() nusoap.php L3718 invoke_method() mantisconnect.php L1717 service() mantisconnect.php L0 {main}()