jlcodes99/cockpit-tools · error

messages.rawLineNoRefreshToken(item.lineNumber)

Error message

messages.rawLineNoRefreshToken(item.lineNumber)

What it means

When importing codex accounts from raw text, each non-empty line must contain exactly one refresh token matching /rt_[A-Za-z0-9._-]+/g. This error (line 336) means a line contained no refresh token at all, so no account could be constructed from it.

Source

Thrown at src/hooks/useProviderAccountsPage.ts:336

  return Boolean(hasFullTokens || hasRefreshTokenOnly);
};

const parseCodexRawRefreshTokenItems = (
  rawContent: string,
  messages: ExternalImportBundleParseMessages,
): unknown[] | null => {
  const lines = rawContent
    .split(/\r?\n/)
    .map((line, index) => ({ line: line.trim(), lineNumber: index + 1 }))
    .filter((item) => item.line.length > 0);

  if (lines.length === 0) return null;

  const items: unknown[] = [];
  for (const item of lines) {
    const matches = [...item.line.matchAll(CODEX_REFRESH_TOKEN_PATTERN)];
    if (matches.length === 0) {
      throw new Error(messages.rawLineNoRefreshToken(item.lineNumber));
    }
    if (matches.length > 1) {
      throw new Error(messages.rawLineMultipleRefreshTokens(item.lineNumber));
    }

    const match = matches[0];
    const refreshToken = match[0].trim();
    const accountNote = item.line.slice(0, match.index ?? 0).trim();
    items.push({
      refresh_token: refreshToken,
      ...(accountNote ? { account_note: accountNote } : {}),
    });
  }

  return items.length > 0 ? items : null;
};

const resolveExternalImportBundleItems = (

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Find the reported line number and add/paste the correct refresh token (it must start with rt_)
  2. Remove lines that are notes, headers, or blank labels without tokens
  3. If the token uses a different prefix, convert/export it into the rt_... format expected by codex
  4. Alternatively wrap the data as proper JSON (single bundle or one JSON object per line) to bypass raw parsing

Example fix

// before (line 3 has no token)
my account one
rt_abc123
notes only here
// after
account one rt_abc123
Defensive patterns

Strategy: validation

Validate before calling

const CODEX_TOKEN = /rt_[A-Za-z0-9._-]+/g;
const bad = content.split(/\r?\n/)
  .map((l, i) => ({ l: l.trim(), n: i + 1 }))
  .filter(x => x.l && ![...x.l.matchAll(CODEX_TOKEN)].length);
if (bad.length) throw new Error(`Line(s) ${bad.map(b => b.n).join(',')} contain no rt_ refresh token`);

Type guard

const hasCodexRefreshToken = (line: string): boolean =>
  /^rt_[A-Za-z0-9._-]+$/.test(line.trim()) ||
  [...line.matchAll(/rt_[A-Za-z0-9._-]+/g)].length === 1;

Try / catch

try {
  items = resolveExternalImportBundleItems(content, 'codex', messages);
} catch (e) {
  if (e instanceof Error && /no refresh token/i.test(e.message)) {
    highlightLineFromMessage(e.message);
  }
}

Prevention

When it happens

Trigger: platformId is 'codex', whole-content JSON.parse failed, line-delimited parsing failed, and a non-empty line of the raw content has no substring matching the rt_ token pattern.

Common situations: Pasting account notes or labels without the token; lines with truncated tokens missing the rt_ prefix; tokens from another provider with a different prefix; stray header/footer text lines in the paste.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/2ac9f057866475ae. Report an issue: GitHub.