Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#17117 closed defect (fixed)

dojo/request/xhr doesn't properly handle falsy

Reported by: Scott Hunter Owned by: Bryan Forbes
Priority: high Milestone: 1.8.11
Component: IO Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:


If I use xhr with handleAs : 'json', and the response JSON entirely consists of:


then the promise resolves to the original response text "false" instead of the JSON parsed, boolean value false. I tracked it down to request/util, where the promise is chained through a function that does:

return || response.text;

The mistake here is using || instead of an undefined check. Even if is falsy, it should be used in preference to the original response text.

Change History (5)

comment:1 Changed 8 years ago by bill

Component: GeneralIO
Owner: set to Bryan Forbes

comment:2 Changed 6 years ago by iDo

Little bump on this one. The problem is still valid.

I created a PR for fixing it:

([PATCH][CLA] can be added to the title)

comment:3 Changed 6 years ago by dylan

Milestone: tbd1.11
Priority: undecidedhigh
Resolution: fixed
Status: newclosed

Fixed via db66e918cd5a736fa4023741ace82e1bdc0fb612 in 1.11

Note the patch does not cleanly backport, so if we want to backport it to 1.10, etc., please provide a pull request against that branch because 1.10 and earlier have their tests using DOH rather than Intern. Thanks!

comment:4 Changed 6 years ago by iDo

@dylan I created a PR for the backport:

comment:5 Changed 6 years ago by dylan


Backported to 1.10, 1.9, and 1.8.

Note: See TracTickets for help on using tickets.