spacebarchat / spacebarchat/server

Empty string on no username

Open
#1,040 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
TypeScript
Stars
2.2k
Forks
323
Avg merge
14h 48m
Merged PRs (30d)
4

Description

Describe the bug
When I send a request to /api/auth/register with the following json body:

{
  "username": "Hi",
  "consent": false
}

I get this error:

{
  "code": 50035,
  "message": "Invalid Form Body",
  "errors": {
    "consent": {
      "_errors": [
        {
          "message": "You must agree to the Terms of Service and Privacy Policy.",
          "code": "CONSENT_REQUIRED"
        }
      ]
    }
  }
}

So far, so good.
However, if I don't supply a username, like this:

{
  "consent": false
}

, the response looks like this:

{
  "code": 50035,
  "message": "Invalid Form Body",
  "errors": {
    "": {
      "_errors": [
        {
          "message": "must have required property 'username'",
          "code": "required"
        }
      ]
    }
  }
}

The field under "errors" is just an empty string. Is this supposed to be like that?

System Information (please complete the following information):

  • OS: Arch btw
  • Node Version: Node v19.9.0
  • Python 3 Version: Python 3.10.10

Env and Software info

  • Branch (if release is not applicable): main
  • Commit Hash: 174d34c376a6a94c88b163cf46f76f2b6e52e633
  • Database: SQLite
  • Reverse Proxy: n.a.
  • Thread Count:

Additional context
i hate json i hate json
i hate json
i hate json
i hate json
i hate json

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the /api/auth/register entry point and reproduce the two request bodies shown in the issue. Trace how validation errors are mapped into the response, then verify that the missing-username case reports the intended field consistently and that both consent and username validation remain covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.