{"record":{"id":"5c500a7625bad31e","repo":"badges/shields","slug":"monitor-api-key-is-unvalid","errorCode":null,"errorMessage":"monitor API key is unvalid","messagePattern":"monitor API key is unvalid","errorType":"exception","errorClass":"InvalidParameter","httpStatus":null,"severity":"error","filePath":"services/uptimeobserver/uptimeobserver-base.js","lineNumber":26,"sourceCode":"const monitorResponse = Joi.object({\n  status: Joi.string().required(),\n  uptime24h: Joi.number().min(0).max(100).required(),\n  uptime7d: Joi.number().min(0).max(100).required(),\n  uptime30d: Joi.number().min(0).max(100).required(),\n}).required()\n\nconst singleMonitorResponse = Joi.alternatives(monitorResponse, errorResponse)\n\nexport default class UptimeObserverBase extends BaseJsonService {\n  static category = 'monitoring'\n\n  static ensureIsMonitorApiKey(value) {\n    if (!value) {\n      throw new InvalidParameter({\n        prettyMessage: 'monitor API key is required',\n      })\n    } else if (value.length <= 32) {\n      throw new InvalidParameter({\n        prettyMessage: 'monitor API key is unvalid',\n      })\n    }\n  }\n\n  async fetch({ monitorKey }) {\n    this.constructor.ensureIsMonitorApiKey(monitorKey)\n\n    // Docs for API: https://support.uptimeobserver.com/shields-api.yaml\n    const url = `https://app.uptimeobserver.com/api/monitor/status/${monitorKey}`\n\n    const response = await this._requestJson({\n      schema: singleMonitorResponse,\n      url,\n      options: {\n        method: 'GET',\n      },\n      logErrors: [],","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/uptimeobserver/uptimeobserver-base.js#L8-L44","documentation":"UptimeObserver's ensureIsMonitorApiKey throws this InvalidParameter when a monitorKey is supplied but is 32 characters or shorter. The service expects a long (presumably 33+ character) monitor-specific API key, so short values are rejected as invalid before any request. Note the service's own spelling: 'unvalid'.","triggerScenarios":"Passing a monitorKey query parameter whose length is <= 32 to any uptime-observer badge; the guard runs inside fetch() before the upstream API call.","commonSituations":"Using a truncated/copy-pasted key; using an account-level key or some other id/token that is not the full monitor key; hand-typing the key and missing characters.","solutions":["Copy the full monitor API key from the UptimeObserver dashboard (do not truncate).","Confirm you are using the monitor-specific key, not another token or the monitor id.","Check for URL/config trimming that could cut the key short (e.g. template truncation, quoting issues)."],"exampleFix":"// before\n?monitorKey=abc123def456 (12 chars)\n// after\n?monitorKey=full-64-character-monitor-key-from-dashboard","handlingStrategy":"validation","validationCode":"if (!monitorKey || monitorKey.length <= 32) throw new Error('monitorKey must be the full monitor API key (>32 chars)')","typeGuard":"const isValidKey = (v) => typeof v === 'string' && v.length > 32","tryCatchPattern":"try { await fetchBadge() } catch (e) { if (e instanceof InvalidParameter) console.error('monitorKey too short — copy the full key'); throw e }","preventionTips":["Copy the whole key in one action from the UptimeObserver dashboard.","Log key length (not content) in CI to catch truncation.","Beware editors/config layers trimming or wrapping long values."],"tags":["bad-request","api-key","validation"],"backgroundTag":"invalid-api-key","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}