Skip to content

Organization ID is not available #13906

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

Closed
emouawad opened this issue Jul 16, 2024 · 21 comments · Fixed by #13917
Closed

Organization ID is not available #13906

emouawad opened this issue Jul 16, 2024 · 21 comments · Fixed by #13917
Labels
waiting-for-info The issue creator is asked to provide more information.

Comments

@emouawad
Copy link

emouawad commented Jul 16, 2024

On the home page, before login:

Unexpected Application Error!
Organization ID is not available.

Github authentication enabled.

Screenshot 2024-07-16 190830

Version:
ghcr.io/coder/coder:v2.13.0

Used env variables:

- CODER_PG_CONNECTION_URL=
- CODER_ACCESS_URL=
- CODER_WILDCARD_ACCESS_URL=

- CODER_EXTERNAL_AUTH_0_ID=
- CODER_EXTERNAL_AUTH_0_TYPE=github
- CODER_EXTERNAL_AUTH_0_CLIENT_ID=
- CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=

- CODER_OAUTH2_GITHUB_ALLOW_SIGNUPS=true
- CODER_OAUTH2_GITHUB_ALLOWED_ORGS=
- CODER_OAUTH2_GITHUB_CLIENT_ID=
- CODER_OAUTH2_GITHUB_CLIENT_SECRET=

What is Organization ID: a github or a coder organization?
From the docs, tried to find if this is a config i can set in coder, nothing!

Weirdly enough:
I run this in kubernetes:

  • port-forwarding (no issues)
  • ingress (Issue persists)
  • istio (no issues)

which led me to think: is this a headers issue?

@coder-labeler coder-labeler bot added the waiting-for-info The issue creator is asked to provide more information. label Jul 16, 2024
@kylecarbs
Copy link
Member

@Emyrk thoughts?

@Emyrk
Copy link
Member

Emyrk commented Jul 16, 2024

I think this is a UI bug. @aslilac?

I will take a look too.

@Emyrk
Copy link
Member

Emyrk commented Jul 16, 2024

https://github.com/coder/coder/blob/stevenmasley%2Fpremium_license/site/src/contexts/auth/RequireAuth.tsx#L91-L93

I wonder if there is a caching issue on the FE code. The value comes from here:

user, err := json.Marshal(db2sdk.User(user, orgIDs))

@emouawad if you force refresh your page to clear any page caching, does the issue persist? And if so, what is the value of the <meta property="user" content="..." /> in the <head> section of the html?

Curious if the organization_ids is empty.

@aslilac
Copy link
Member

aslilac commented Jul 16, 2024

Curious if the organization_ids is empty.

Boolean([]) === true, so organization_ids being present but empty would not fail this check. It would have to undefined or null or some other value that would convert to false.

@emouawad
Copy link
Author

emouawad commented Jul 17, 2024

https://github.com/coder/coder/blob/stevenmasley%2Fpremium_license/site/src/contexts/auth/RequireAuth.tsx#L91-L93

I wonder if there is a caching issue on the FE code. The value comes from here:

user, err := json.Marshal(db2sdk.User(user, orgIDs))

@emouawad if you force refresh your page to clear any page caching, does the issue persist? And if so, what is the value of the <meta property="user" content="..." /> in the <head> section of the html?

Curious if the organization_ids is empty.

Incognito mode.

Could that be headers related? i wonder why it has different outcome depends which ingress i choose.

Btw i tested older versions - it still fails with a generic error - newer versions are handling the error better though.

image

@Emyrk
Copy link
Member

Emyrk commented Jul 17, 2024

@emouawad huh, so you are not authenticated and you are getting that error. Do you have a network request that ends in /me that is returning something? Clearing your cookies might help if there is some strange authentication state.

newer versions are handling the error better though.

What is "better"?


@aslilac has made a PR that drops the possibility of that error from occurring, when that patch makes it's way to live.

@emouawad
Copy link
Author

YES not authenticated yet, and new incognito window and cleared the cookies.

Yeh, i noticed the PR, i can retest as soon as this is deployed - meanwhile these are the calls if it helps:

https://coder.website.com/api/v2/users/me

{
  "error": true,
  "code": 401,
  "message": "Unauthorized",
  "description": "The requested page needs a username and a password"
}

https://coder.website.com/api/v2/users/first

{
  "error": true,
  "code": 404,
  "message": "Not Found",
  "description": "The server can not find the requested page"
}

https://coder.website.com/api/v2/authcheck

{
  "error": true,
  "code": 401,
  "message": "Unauthorized",
  "description": "The requested page needs a username and a password"
}

@Emyrk
Copy link
Member

Emyrk commented Jul 17, 2024

@emouawad appreciate all the data. The new PR just removes that code (was dead code anyway), so it should be fixed when it goes live.

Nothing seems obvious from what you sent, I was curious if there was some strange auth state with the cookies going on, but that does not seem to be the case.

@emouawad
Copy link
Author

emouawad commented Jul 19, 2024

Please reopen this issue. @Emyrk @aslilac
Latest release did not fix it - it's now generating a new error.

Unexpected Application Error!
Cannot read properties of undefined (reading '0')

image

@Emyrk Emyrk reopened this Jul 19, 2024
@Emyrk
Copy link
Member

Emyrk commented Jul 19, 2024

@emouawad this PR was merged yesterday that deleted that line that errored. The first PR ripped out the original error, and after looking further this was the follow up to rip out some other org context code.

#13940

Are you able to deploy the latest main, or just releases?

@aslilac
Copy link
Member

aslilac commented Jul 19, 2024

Hmm. @Emyrk we could replace this line with "00000000-0000-0000-0000-000000000000", but that still doesn't get to the root of this issue. It's bizarre that this property is ending up undefined somehow.

@Emyrk
Copy link
Member

Emyrk commented Jul 19, 2024

@aslilac
Copy link
Member

aslilac commented Jul 19, 2024

yes, but we did that change after the release, so the 2.13 branch still looks like this: https://github.com/coder/coder/blob/release/2.13/site/src/modules/dashboard/DashboardProvider.tsx#L47

@matifali
Copy link
Member

@emouawad these changes should be available in next mainline release (7th of August) you can test them now using ghcr.io/coder/coder-preview images.

@emouawad
Copy link
Author

emouawad commented Jul 20, 2024

@matifali Still reproducible with ghcr.io/coder/coder-preview:main-2.13.1-devel-a8e6e89f6

Unexpected Application Error!
r.includes is not a function

image

@Parkreiner
Copy link
Member

I'm digging around a little bit, and I'm wondering if there might be an issue with what we're sending from the server. As in, we're sending a valid JSON value, and it's fully defined – but it happens to be of a type that the frontend isn't expecting

Tomorrow I'm going to do some more digging.

More context

The minified r variable refers to the list of Coder experiments that a deployment has enabled. It's supposed to be an array of strings, with the presence of a string indicating that an experiment is enabled

We have checks in place to ensure that the UI will be stuck in a loading state if the value is ever undefined (especially during the initial loading). The UI is getting past the loading state no problem, though, and I don't see a way for an undefined value to ever slip through. But if we're accidentally sending an incorrect type back, that would be able to bypass the checks while still causing the .includes method call to be invalid. That seems like the most likely candidate to me, and TypeScript might not be able to catch this

@emouawad
Copy link
Author

image

/v2/experiments and /v2/appearance is returning 401

/v2/entitelements is returning

{
    "features": {
        "access_control": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "advanced_template_scheduling": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "appearance": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "audit_log": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "browser_only": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "control_shared_ports": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "custom_roles": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "external_provisioner_daemons": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "external_token_encryption": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "high_availability": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "multiple_external_auth": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "multiple_organizations": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "scim": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "template_rbac": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "user_limit": {
            "entitlement": "not_entitled",
            "enabled": false,
            "actual": 1
        },
        "user_role_management": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "workspace_batch_actions": {
            "entitlement": "not_entitled",
            "enabled": false
        },
        "workspace_proxy": {
            "entitlement": "not_entitled",
            "enabled": false
        }
    },
    "warnings": [],
    "errors": [],
    "has_license": false,
    "trial": false,
    "require_telemetry": false,
    "refreshed_at": "2024-07-24T04:42:38.327141842Z"
}

@aslilac
Copy link
Member

aslilac commented Jul 24, 2024

@emouawad are you running this deployment behind a proxy or anything? I know the code field shows a 401, but can you verify that the actual status code of the HTTP response is indeed a 401?

@emouawad
Copy link
Author

I am running this behind ingress-nginx with no authentication in GKE.
Not sure i got the question right: "code field" ?

All the network requests return 200 success.

image

@aslilac
Copy link
Member

aslilac commented Jul 24, 2024

ok, well this is definitely the problem

in the debugger screenshot you shared above, that r value means that /experiments should have replied with a 401 HTTP status, but instead it's coming through as a 200, which means the app is assuming that it's the correct type for a successful response (ie. should have an experiments field).

can you try curl -v https://yourcodedeployment/api/v2/experiments without nginx in the middle and see what the HTTP status is that way? I feel like nginx isn't carrying the status correctly here.

@emouawad
Copy link
Author

Issue solved now by removing the ingress-nginx default-backend that redirected 401 to a custom web page. (Not newly introduced) - There must have been a change on coder that affected this - previously was working fine with the default redirect in place.

Thanks for helping! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-info The issue creator is asked to provide more information.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants