{"record":{"id":"0e3e2e1c127d287f","repo":"nocobase/nocobase","slug":"the-saved-license-key-does-not-include-package-reg","errorCode":null,"errorMessage":"The saved license key does not include package registry credentials.","messagePattern":"The saved license key does not include package registry credentials\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/cli/src/commands/license/plugins/shared.ts","lineNumber":92,"sourceCode":"async function pathExists(target: string): Promise<boolean> {\n  try {\n    await access(target);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nfunction trimString(value: unknown): string | undefined {\n  const text = String(value ?? '').trim();\n  return text || undefined;\n}\n\nasync function loginPkg(baseURL: string, keyData: LicenseKeyData): Promise<string> {\n  const username = String(keyData.accessKeyId ?? '').trim();\n  const password = String(keyData.accessKeySecret ?? '').trim();\n  if (!username || !password) {\n    throw new Error('The saved license key does not include package registry credentials.');\n  }\n\n  const response = await fetch(`${baseURL}-/verdaccio/sec/login`, {\n    method: 'POST',\n    headers: {\n      'content-type': 'application/json',\n    },\n    body: JSON.stringify({ username, password }),\n  });\n  if (!response.ok) {\n    throw new Error(`Package registry login failed with status ${response.status}.`);\n  }\n  const data = await response.json();\n  const token = String(data?.token ?? '').trim();\n  if (!token) {\n    throw new Error('Package registry login did not return a token.');\n  }\n  return token;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/cli/src/commands/license/plugins/shared.ts#L74-L110","documentation":"The license plugin's loginPkg exchanges the saved license key's package-registry credentials (accessKeyId/accessKeySecret) with a Verdaccio login endpoint. If the saved license key data lacks either credential, it throws this plain Error. The license key is valid but does not carry npm-registry credentials, so private packages cannot be fetched.","triggerScenarios":"Calling `token` (which calls loginPkg) with a LicenseKeyData parsed from a key that has empty/missing accessKeyId or accessKeySecret fields.","commonSituations":"A license key issued for a tier or era without registry credentials; a corrupted/truncated key string; key pasted from an old export format.","solutions":["Re-obtain and re-save a license key that includes package registry credentials (re-activate the license).","Verify the key data contains accessKeyId and accessKeySecret before calling the token command.","Contact NocoBase support if your purchased tier should include private plugin registry access."],"exampleFix":"// before\nif (!keyData.accessKeyId || !keyData.accessKeySecret) { /* runtime throws */ }\n// after\nconst hasCreds = typeof keyData.accessKeyId === 'string' && keyData.accessKeyId.length > 0 && typeof keyData.accessKeySecret === 'string' && keyData.accessKeySecret.length > 0;\nif (!hasCreds) throw new Error('Re-activate license: key lacks registry credentials');","handlingStrategy":"validation","validationCode":"const keyData = /* parsed saved license key */;\nif (!String(keyData.accessKeyId ?? '').trim() || !String(keyData.accessKeySecret ?? '').trim()) {\n  console.error('Saved license key lacks package registry credentials; re-activate the license first.');\n  process.exit(1);\n}","typeGuard":"function hasRegistryCredentials(k): k is LicenseKeyData & { accessKeyId: string; accessKeySecret: string } {\n  return typeof k.accessKeyId === 'string' && k.accessKeyId.trim().length > 0 &&\n         typeof k.accessKeySecret === 'string' && k.accessKeySecret.trim().length > 0;\n}","tryCatchPattern":"try {\n  const token = await token(runtime);\n} catch (error) {\n  if (/does not include package registry credentials/.test(String(error.message))) {\n    console.error('Re-activate your license key to obtain registry credentials.');\n  }\n  throw error;\n}","preventionTips":["Re-activate the license after key rotation or plan changes.","Validate key fields right after saving/activating, before licensed operations.","Keep keys from an untruncated source (copy full string; avoid shell mangling)."],"tags":["license","authentication","npm-registry","cli"],"backgroundTag":"missing-registry-credentials","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}