Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: Cannot destructure property 'points' of 'entities.user[username]' as it is undefined. #6998

Closed
sentry-io bot opened this issue Sep 8, 2021 · 2 comments · Fixed by #7016
Closed
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge

Comments

@sentry-io
Copy link

sentry-io bot commented Sep 8, 2021

Sentry Issue: SHIELDS-6M

TypeError: Cannot destructure property 'points' of 'entities.user[username]' as it is undefined.
  File "/app/services/freecodecamp/freecodecamp-points.service.js", line 58, in Function.transform
    const { points } = entities.user[username]
  File "/app/services/freecodecamp/freecodecamp-points.service.js", line 67, in FreeCodeCampPoints.handle
    const points = this.constructor.transform(response, username)
  ?, in runMicrotasks
  File "/app/core/base-service/base.js", line 403, in async Function.invoke
    serviceData = await serviceInstance.handle(
  File "/app/core/base-service/base.js", line 445, in async Object.handler
    const serviceData = await this.invoke(
...
(1 additional frame(s) were not displayed)
@chris48s chris48s added bug Bugs in badges and the frontend service-badge New or updated service badge labels Sep 8, 2021
@calebcartwright
Copy link
Member

@SethFalco - you'd recently worked on the this service, so curious if you have any ideas? I'm not sure how this would be happening from a cursory glance at the code and the API response under various conditions. Wondering if it could be something encoded related with the username (e.g. a username containing a space or some other escaped character)

@SethFalco
Copy link
Contributor

SethFalco commented Sep 13, 2021

Just gave this a peek, but without knowing the input I'm a bit confused how this occurred, to be honest.
Spaces aren't allowed in a freeCodeCamp username either, so that shouldn't be it I don't think. (at least not directly)

const isValidUsername = str => {
  if (!validCharsRE.test(str)) return invalidCharError;
  if (str.length < 3) return usernameTooShort;
  if (isHttpStatusCode(str)) return usernameIsHttpStatusCode;
  if (!isUsernameLowercase(str)) return usernameUpperCase;
  return validationSuccess;
};

https://github.com/freeCodeCamp/freeCodeCamp/blob/main/utils/validate.js#L20

  • Basically, it can only have characters a-z, A-Z, 0-9, -, _, and +.
  • Must be at least 2 characters.
  • Can't be an HTTP status code?
  • Can't have uppercase characters.

Based on this the issue is most likely the + symbol that can be used in usernames. I've just reproduced the internal server error as well. I'll tackle this soon!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Bugs in badges and the frontend service-badge New or updated service badge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants