Plant-for-the-Planet-org / treecounter-app

Plant-for-the-Planet App allows you to plant trees with over 100 reforestation projects around the world.
https://www.trilliontreecampaign.org
Other
41 stars 18 forks source link

Error in app/actions/loadTposAction.js:11 #1064

Closed Plant-for-the-Planet closed 4 years ago

Plant-for-the-Planet commented 5 years ago

Error in Plant-for-the-Planet App

Error in app/actions/loadTposAction.js:11 Unexpected input given to normalize. Expected type to be "object", found "string".

View on Bugsnag

Stacktrace

https://github.com/Plant-for-the-Planet-org/treecounter-app/blob/01f4514299eaf445d4b4f430593e423397340e5c/app/actions/loadTposAction.js#L12

export function loadTpos() {
  const request = getRequest('data_tpos_get');
  return dispatch => {
    request
      .then(res => {
        dispatch(mergeEntities(normalize(res.data, [tpoSchema])));
      })
      .catch(error => console.log(error));
  };
}

View full stacktrace

Created automatically via Bugsnag

norbertschuler commented 4 years ago

One of the most common bugs in Bugsnag still happening.

SupriyaAdep commented 4 years ago

Hey @norbertschuler, how to reproduce the mentioned bug?

Supriya from Mumbai at WomenWhoCode hacktoberfest.

norbertschuler commented 4 years ago

@SupriyaAdep I am sorry, the GitHub issue does not show the whole information we have, but Bugsnag isn't public. I just recognized this issue only happens in our native app (iOS and Android app), not in the web client, so maybe it's a bad choice for Hacktoberfest.

Update: I am currently unable to give a documentation about how to reproduce this bug.

SupriyaAdep commented 4 years ago

Hi @norbertschuler thank you for the update.

norbertschuler commented 4 years ago

I'd tried to reproduce this, but wasn't able yet.

norbertschuler commented 4 years ago

I found this stack trace where the error is thrown, so the error results from some API response not being returned as an object (could be also an empty string, but not null or undefined) - since the backend response is handled by the axios npm module we can currently not fix this in another way as catching this error, so the user does not get it, but then there are no TPOs loaded for the application so it doesn't make any sense to use the app any more:

var normalize$1 = function normalize(input, schema) {
 if (!input \|\| typeof input !== 'object') {
  throw new Error("Unexpected input given to normalize. Expected type to be \"object\", found \"" + typeof input + "\".");
 }
 ...
norbertschuler commented 4 years ago

As this API call is not deprecated, this error could have been vanished.