Skip to content

cursor-sdk auth.md: non-null assertion described as a runtime missing-variable check #473

Description

@Authentis

Observed at commit 2eb7ed4: cursor-sdk/skills/cursor-sdk/references/auth.md line 45.

The text reads:

The non-null assertion (!) is a readable way to say "fail loudly if the env var is missing" — otherwise the SDK will throw an auth error later and the stack trace won't point at the env var.

for the example apiKey: process.env.CURSOR_API_KEY!.

Problem

In TypeScript the postfix ! is a compile-time-only assertion; it is erased in emitted JavaScript and performs no runtime check. If CURSOR_API_KEY is unset, undefined is passed through and the failure appears later in the SDK, exactly the outcome the sentence says ! avoids.

Suggested fix

Reword to say that ! only silences the type error and does no check, and lead with the explicit check that is already shown a few lines below:

const apiKey = process.env.CURSOR_API_KEY;
if (!apiKey) {
  console.error("Missing CURSOR_API_KEY. ...");
  process.exit(1);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions