[GH-ISSUE #520] Error: Unexpected token 'U', "Unauthorized" is not valid JSON #305

Closed
opened 2026-02-22 18:18:52 -05:00 by yindo · 7 comments
Owner

Originally created by @bkowshik on GitHub (Jan 3, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/520

Get the following error when I try to create a new workspace.

Error: Unexpected token 'U', "Unauthorized" is not valid JSON

Screenshot 2024-01-04 at 10 12 20 AM

Steps

  1. Create a new invitation for a new user.
  2. In a Private window, open the invitation and signup as a new user.
  3. Create a new Workspace using the button in the onboarding.
Originally created by @bkowshik on GitHub (Jan 3, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/520 Get the following error when I try to create a new workspace. > Error: Unexpected token 'U', "Unauthorized" is not valid JSON <img width="1440" alt="Screenshot 2024-01-04 at 10 12 20 AM" src="https://github.com/Mintplex-Labs/anything-llm/assets/2899501/482aec7a-a1f7-423b-8d84-64179dee812e"> ## Steps 1. Create a new invitation for a new user. 2. In a Private window, open the invitation and signup as a new user. 3. Create a new Workspace using the button in the onboarding.
yindo added the good first issuebugUI/UX labels 2026-02-22 18:18:52 -05:00
yindo closed this issue 2026-02-22 18:18:52 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jan 4, 2024):

Ah, it is because you are clicking on the "Create First Workspace" in the messages in the default view, but in multi user mode the creation of workspaces for users is disabled, thus Unauthorized

As an admin, if you enabled "Users can create workspaces" in settings this would not longer occur.

@timothycarambat commented on GitHub (Jan 4, 2024): Ah, it is because you are clicking on the "Create First Workspace" in the messages in the default view, but in multi user mode the creation of workspaces for users is disabled, thus `Unauthorized` As an admin, if you enabled "Users can create workspaces" in settings this would not longer occur.
Author
Owner

@bkowshik commented on GitHub (Jan 4, 2024):

@timothycarambat Would you estimate this to be a Good first issue?

I would like to take a stab at making a contribution if possible, might need some support. I love this project and see myself contributing and this might be a good place to start.

@bkowshik commented on GitHub (Jan 4, 2024): @timothycarambat Would you estimate this to be a `Good first issue`? I would like to take a stab at making a contribution if possible, might need some support. I love this project and see myself contributing and this might be a good place to start.
Author
Owner

@timothycarambat commented on GitHub (Jan 4, 2024):

@bkowshik I think so!

In general, what needs to be check is if those buttons should display based on the user object which can be gotten from useUser hook. This only applies if the instance admin did not set the welcome messages to something custom.

https://github.com/Mintplex-Labs/anything-llm/blob/master/frontend/src/components/DefaultChat/index.jsx#L21

Add const {user} = useUser() to top of component.

Then in all places there is a CTA to create a workspace in the MESSAGES array you can change

 <button
    onClick={showNewWsModal}
    className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800">
    <Plus className="h-4 w-4" />
    <p>Create your first workspace</p>
</button>

to

 {(!user || user?.role !== "default") && (
 <button
    onClick={showNewWsModal}
    className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800">
       <Plus className="h-4 w-4" />
       <p>Create your first workspace</p>
 </button>
 )}

This will show the button when no user is defined (single user mode) and if the user is defined, such as in multi-user mode, make sure the role is not default. All new users are default when created unless otherwise specified by the admin. default users cannot create workspaces!

@timothycarambat commented on GitHub (Jan 4, 2024): @bkowshik I think so! In general, what needs to be check is if those buttons should display based on the `user` object which can be gotten from `useUser` hook. This only applies if the instance admin did not set the welcome messages to something custom. https://github.com/Mintplex-Labs/anything-llm/blob/master/frontend/src/components/DefaultChat/index.jsx#L21 Add `const {user} = useUser()` to top of component. Then in all places there is a CTA to create a workspace in the `MESSAGES` array you can change ```jsx <button onClick={showNewWsModal} className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800"> <Plus className="h-4 w-4" /> <p>Create your first workspace</p> </button> ``` to ```jsx {(!user || user?.role !== "default") && ( <button onClick={showNewWsModal} className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800"> <Plus className="h-4 w-4" /> <p>Create your first workspace</p> </button> )} ``` This will show the button when no user is defined (single user mode) and if the user *is* defined, such as in multi-user mode, make sure the role is not default. All new users are `default` when created unless otherwise specified by the admin. `default` users cannot create workspaces!
Author
Owner

@ElvinPero commented on GitHub (Jan 4, 2024):

@timothycarambat Can I work on this issue?

@ElvinPero commented on GitHub (Jan 4, 2024): @timothycarambat Can I work on this issue?
Author
Owner

@KaushalSoniii commented on GitHub (Jan 4, 2024):

@timothycarambat Can I work on this issue?

anyone can fix this issue!

@KaushalSoniii commented on GitHub (Jan 4, 2024): > @timothycarambat Can I work on this issue? anyone can fix this issue!
Author
Owner

@timothycarambat commented on GitHub (Jan 4, 2024):

Whoever wants to work it just assign the issue to yourself so its not double-worked and somebody wastes their time :)

@timothycarambat commented on GitHub (Jan 4, 2024): Whoever wants to work it just assign the issue to yourself so its not double-worked and somebody wastes their time :)
Author
Owner

@timothycarambat commented on GitHub (Jan 9, 2024):

closed by 5172bceec3

@timothycarambat commented on GitHub (Jan 9, 2024): closed by 5172bceec3f34b10ef4e96da0a6b659ccaee1f07
yindo changed title from Error: Unexpected token 'U', "Unauthorized" is not valid JSON to [GH-ISSUE #520] Error: Unexpected token 'U', "Unauthorized" is not valid JSON 2026-06-05 14:34:36 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#305