{ "id": "63894", "key": "TIMOB-3262", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2017-06-12T18:28:16.000+0000", "created": "2011-04-15T03:40:42.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "api" ], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-12T18:28:16.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Problem

\r\n

Assume that we have a \"person\" variable returned from calling\r\nTi.Contacts.showContacts({ selectedPerson: ... }) call. If you do\r\nsomething to turn person.email.work into a string such as 'Work: '\r\n+ person.email.work, the \"Cannot find default value for object\"\r\nerror is displayed.

\r\n

Kroll attempts to access person.email.home, which is an\r\nArrayList (ref: \r\nPersonProxy.java#69). It doesn't know how to turn this into a\r\nstring, so the error is displayed.

\r\n

Solution

\r\n

The real problem here is that we get a very obtuse error message\r\nwhen you try to do something common (print out a variable for\r\ndebugging purposes). If we could receive an actual array from\r\nperson.email.home, it could be stringified into its values, and\r\nthis problem would be avoided entirely.

\r\n

Sample Code

\r\n
\r\nvar win = Titanium.UI.createWindow({\r\n    backgroundColor:'#fff'\r\n});\r\n\r\nvar label = Ti.UI.createLabel({\r\n    top: 0, right: 0, bottom: 70, left: 0,\r\n    text: 'Pick Someone With a \"Home\" Email, and you should receive an error message \"Cannot find default value for object\".'\r\n});\r\nwin.add(label);\r\n\r\nvar button = Ti.UI.createButton({\r\n    title: 'Show Contacts',\r\n    bottom: 20,\r\n    width: 200,\r\n    height: 40\r\n});\r\nbutton.addEventListener('click', function() {\r\n    Titanium.Contacts.showContacts({\r\n        selectedPerson: function(e) {\r\n            alert(String(e.person.email.home)); // this will throw the \"cannot find default value for object\" error\r\n            // and the .length call below will have problems if the person doesn't have any home email addresses\r\n            for (var i = 0, l = e.person.email.home.length; i < l; i++) {\r\n                alert(i + ': ' + e.person.email.home[i]);\r\n            }\r\n        }\r\n    });\r\n});\r\nwin.add(button);\r\n\r\nwin.open();\r\n
\r\n

Steps to Reproduce

\r\n
    \r\n
  1. Drop the above into an app.js
  2. \r\n
  3. Launch it and touch the \"Show Contacts\" button.
  4. \r\n
  5. Pick someone who has an email address with the \"Home\"\r\ntype
  6. \r\n
  7. You'll see the error
  8. \r\n
\r\n

Trace Level Log

\r\n
\r\nI/ActivityManager( 2456): Displayed activity com.android.contacts/.ContactsListActivity: 779 ms (total 779 ms)\r\nV/WindowManager( 2456): Dsptch > Window{4823c0f8 com.android.contacts/com.android.contacts.ContactsListActivity paused=false}\r\nV/InputDevice( 2456): ID[0]=0(0) Dn(0=>1)\r\nV/WindowManager( 2456): Dsptch > Window{4823c0f8 com.android.contacts/com.android.contacts.ContactsListActivity paused=false}\r\nV/InputDevice( 2456): ID[0]=0(0) Up(1=>0)\r\nI/ContactsListActivity(24230): uri is content://com.android.contacts/contacts/lookup/3521i25c61c248f9cab48.1998r770-2C2C4E484652484E52484E34424248/529\r\nD/ContactsListActivity(24230): onPause------------------------------------------\r\nI/TiRootActivity(21253): (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@47cf94c0\r\nE/KrollCallback(21253): (kroll$1: app://app.js) [111,111] ECMA Error evaluating source, invocation: [callMethod (anonymous) org.appcelerator.titanium.kroll.KrollCallback@47caeb98], message: TypeError: Cannot find default value for object. (file:///android_asset/Resources/app.js#19)\r\nE/KrollCallback(21253): org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object. (file:///android_asset/Resources/app.js#19)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3761)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3739)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3767)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3779)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:839)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:758)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.NativeArray.getDefaultValue(NativeArray.java:522)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.toString(ScriptRuntime.java:790)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.NativeString.execIdCall(NativeString.java:259)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1711)\r\nE/KrollCallback(21253):     at script(file:///android_asset/Resources/app.js:19)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3161)\r\nE/KrollCallback(21253):     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)\r\nE/KrollCallback(21253):     at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)\r\nE/KrollCallback(21253):     at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164)\r\nE/KrollCallback(21253):     at android.os.Handler.handleCallback(Handler.java:587)\r\nE/KrollCallback(21253):     at android.os.Handler.dispatchMessage(Handler.java:92)\r\nE/KrollCallback(21253):     at android.os.Looper.loop(Looper.java:123)\r\nE/KrollCallback(21253):     at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:89)\r\nE/TiJSError(21253): (kroll$1: app://app.js) [4,115] ----- Titanium Javascript Runtime Error -----\r\nE/TiJSError(21253): (kroll$1: app://app.js) [1,116] - In file:///android_asset/Resources/app.js:19,0\r\nE/TiJSError(21253): (kroll$1: app://app.js) [0,116] - Message: TypeError: Cannot find default value for object. (file:///android_asset/Resources/app.js#19)\r\nE/TiJSError(21253): (kroll$1: app://app.js) [0,116] - Source: null\r\n
\r\n

Tested On

\r\n

Titanium SDK version: 1.6.0 (02/23/11 12:34 9882e81)
\r\nTitanium SDK version: 1.7.0 (03/03/11 10:45 87a2113...)
\r\nBROKEN on Android Emulator 2.2 APIs
\r\nBROKEN on Android Device Epic 4G 2.2

\r\n

Associated Helpdesk Ticket

\r\n

http://developer.appcelerator.com/helpdesk/view/76227

{html}", "attachment": [], "flagged": false, "summary": "Android: Contact Email and Phone Throw \"Cannot find default value for object\" When Stringified", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": null, "comment": { "comments": [ { "id": "130414", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "{html}

My \"alert(String(e.person.email.home));\" example is a bit\nobtuse; you could instead imagine the user doing\n\"Ti.API.info('MyApp :: Contacts :: Receive email back, with home: '\n+ e.person.home)\" and receiving the cryptic problem I have created\nthis issue to resolve.

{html}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:40:43.000+0000", "updated": "2011-04-15T03:40:43.000+0000" }, { "id": "130415", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Putting in 1.7.0 bucket to try and have it solved in that\ntimeframe.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:40:43.000+0000", "updated": "2011-04-15T03:40:43.000+0000" }, { "id": "217499", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "Not sure if I am reproducing this problem correctly or not, but this is what I get:\r\n\r\n{code}\r\nLocation: [22, 52] app.js\r\nMessage: Uncaught TypeError: Cannot read property 'length' of undefined\r\nSource: for (car i = 0, l = e.person.email.home.length; i < l; i++) {\r\n{code}\r\n\r\nTested on a Samsung Galaxy S2 using TiSDK 2.2.0v20120904101713.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-09-04T14:06:30.000+0000", "updated": "2012-09-04T14:06:30.000+0000" }, { "id": "285342", "author": { "name": "bijuexalture", "key": "bijuexalture", "displayName": "Biju pm", "active": true, "timeZone": "Asia/Kolkata" }, "body": "The issue cannot reproduce with the release master 3.2.0\nTested with: \nTitanium Studio, build: 2.1.2.201208301612\nTitanium SDK version: 3.2.0\nTested on\nDevice: Samsung galaxy s duos Android version: 4.0.4\n", "updateAuthor": { "name": "bijuexalture", "key": "bijuexalture", "displayName": "Biju pm", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-12-20T06:40:41.000+0000", "updated": "2013-12-20T06:40:41.000+0000" }, { "id": "421754", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket with reference to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-06-12T18:28:16.000+0000", "updated": "2017-06-12T18:28:16.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }