Skip to content

Commit

Permalink
The response from dataproviders here can return data===null in additi…
Browse files Browse the repository at this point in the history
…on to being simply undefined. This corrects the logic shortcutting and prevents errors like 'Cannot read property 'min' of null'
  • Loading branch information
dannon committed Mar 25, 2016
1 parent 8accc56 commit 7d1b525
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/galaxy/scripts/viz/trackster/tracks.js
Expand Up @@ -2507,7 +2507,7 @@ extend(Track.prototype, Drawable.prototype, {
var data = result.data;

// Tracks may not have stat data either because there is no data or data is not yet ready.
if (data !== undefined && data.min !== undefined && data.max !== undefined) {
if (data && data.min !== undefined && data.max !== undefined) {

This comment has been minimized.

Copy link
@martenson

martenson Mar 30, 2016

Member

Won't this create an Uncaught ReferenceError: data is not defined in case result.data above is undefined? Are we guaranteed to have result.data? ping @dannon

This comment has been minimized.

Copy link
@dannon

dannon Mar 30, 2016

Author Member

Not in my testing. Are you seeing that?

This comment has been minimized.

Copy link
@martenson

martenson Apr 1, 2016

Member

If the presence of data is guaranteed I do not understand the presence of this part if (data &&

If it is not guaranteed the if (data && data.min !== undefined && data.max !== undefined) will result in the above error if (data === undefined).

Am I wrong here? @guerler

What is the purpose of the change in this line?

This comment has been minimized.

Copy link
@dannon

dannon Apr 1, 2016

Author Member

Data can be undefined or null. This fixes an error in the case where it is null, yet we tried to access fields of the null variable anyway.

This comment has been minimized.

Copy link
@martenson

martenson Apr 1, 2016

Member

After messing with null undefined and ReferenceError in JS playground I think this is a correct solution. Please disregard my comments.

// Compute default minimum and maximum values
var min_value = data.min,
max_value = data.max;
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/api/datasets.py
Expand Up @@ -154,7 +154,7 @@ def _data( self, trans, dataset, chrom, low, high, start_val=0, max_vals=None, *
if msg:
return msg

# Get datasources and check for essages.
# Get datasources and check for messages.
data_sources = dataset.get_datasources( trans )
messages_list = [ data_source_dict[ 'message' ] for data_source_dict in data_sources.values() ]
return_message = self._get_highest_priority_msg( messages_list )
Expand Down Expand Up @@ -249,7 +249,7 @@ def _raw_data( self, trans, dataset, provider=None, **kwargs ):

registry = trans.app.data_provider_registry

# allow the caller to specifiy which provider is used
# allow the caller to specify which provider is used
# pulling from the original providers if possible, then the new providers
if provider:
if provider in registry.dataset_type_name_to_data_provider:
Expand Down
2 changes: 1 addition & 1 deletion static/maps/viz/trackster/tracks.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/viz/trackster/tracks.js

Large diffs are not rendered by default.

0 comments on commit 7d1b525

Please sign in to comment.