Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New instance after creating account fails at environments.single TRPC command #19

Open
ajoslin opened this issue Oct 20, 2024 · 5 comments

Comments

@ajoslin
Copy link

ajoslin commented Oct 20, 2024

Hi team, I'm attempting to switch from cloud to the self hosted server.

I'm using the Docker setup on latest version and having trouble getting fully running.

I'm getting a failure after creating a new instance with a fresh account at /api/trpc/environments.single

GET /api/trpc/environments.single?batch=1&input=%7B%220%22%3A%7B%22json%22%3A%7B%22slug%22%3Anull%7D%2C%22meta%22%3A%7B%22values%22%3A%7B%22slug%22%3A%5B%22undefined%22%5D%7D%7D%7D%7D

It just returns a 400 over and over. The response payload is likeso:

[
    {
        "id": null,
        "error": "(function(a){return {message:a,code:-32600,data:{code:a,httpStatus:400,stack:\"TRPCError: BAD_REQUEST\\n    at Array.organizationMiddleware (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fdist\\u002Fsrc\\u002Fserver\\u002Ftrpc\\u002Futil.js:195:15)\\n    at callRecursive (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:119:69)\\n    at next (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:126:26)\\n    at Array.authenticatedMiddleware (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fdist\\u002Fsrc\\u002Fserver\\u002Ftrpc\\u002Futil.js:178:12)\\n    at callRecursive (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:119:69)\\n    at Procedure.call (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:144:26)\\n    at Router.call (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:378:22)\\n    at Object.query (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002Frouter-ee876044.cjs.dev.js:384:21)\\n    at Object.callProcedure (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002FtransformTRPCResponse-36a41418.cjs.dev.js:12:19)\\n    at \\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002FresolveHTTPResponse-ab01e4b9.cjs.dev.js:205:52\\n    at Array.map (\\u003Canonymous\\u003E)\\n    at Object.resolveHTTPResponse (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002FresolveHTTPResponse-ab01e4b9.cjs.dev.js:201:48)\\n    at async Object.nodeHTTPRequestHandler (\\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fdist\\u002FnodeHTTPRequestHandler-9a93c255.cjs.dev.js:68:18)\\n    at async \\u002Fusr\\u002Flocal\\u002Flib\\u002Fnode_modules\\u002F@interval\\u002Fserver\\u002Fnode_modules\\u002F@trpc\\u002Fserver\\u002Fadapters\\u002Fexpress\\u002Fdist\\u002Ftrpc-server-adapters-express.cjs.dev.js:15:5\",path:\"environments.single\"}}}(\"BAD_REQUEST\"))"
    }
]

It's spitting some stacktrace into the response. Nothing in the logs on the server.

Any idea on this?

@theBeardA
Copy link

Any luck with this issue. I am facing exactly same issue

@heldrida
Copy link

heldrida commented Nov 1, 2024

If you look at the error message, the one above is very hard to read, but if you try to get the text terms, you find a call to organizationMiddleware and then authenticatedMiddleware. You know that the error message says BAD_REQUEST, which for the organizationMiddleware bit points to the source-code here:

// This relies on a header set by the client config if
// used within DashboardContext. Will not work elsewhere.
export const organizationMiddleware: MiddlewareFunction<
  AuthenticatedContext,
  OrganizationContext,
  unknown
> = ({ ctx, next }) => {
  if (!ctx.organizationId) {
    throw new trpc.TRPCError({ code: 'BAD_REQUEST' })
  }
  ...

Seem like missing environment variables and user fault?

@ajoslin
Copy link
Author

ajoslin commented Nov 5, 2024

Thanks for the response - how should I be setting organization id then? Not sure how that works, and having a hard time figuring it out in the source code. Not seeing any documented environment variables, and it looks like it's retrieved from the database at runtime.

@ajoslin
Copy link
Author

ajoslin commented Nov 5, 2024

Currently I'm setting APP_URL, DATABASE_URL, AUTH_COOKIE_SECRET, and WSS_API_SECRET only.

@austinjeane
Copy link

@ajoslin The issue is probably your reverse proxy setup. I had the same error, and it was due to the the cookies with underscores "_" being in the cookie names. NGINX for instance will strip all cookies with underscores as not valid. I had to add this to my NGINX config then it worked.

server {                                                                     
    server_name test.com;                                    
    underscores_in_headers on;                                               
                                                                             
    location / {                                                             
        proxy_pass_request_headers on;                                       
        proxy_pass http://localhost:3000;                                    
         ... rest of config here              
    }          
                                                              
      ... rest of config here                                                                   
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants