{"record":{"id":"fd9db97d60e9fe17","repo":"badges/shields","slug":"monitor-api-key-is-required","errorCode":null,"errorMessage":"monitor API key is required","messagePattern":"monitor API key is required","errorType":"exception","errorClass":"InvalidParameter","httpStatus":null,"severity":"error","filePath":"services/uptimeobserver/uptimeobserver-base.js","lineNumber":22,"sourceCode":"const errorResponse = Joi.object({\n  error: Joi.string().required(),\n}).required()\n\nconst 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,","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/uptimeobserver/uptimeobserver-base.js#L4-L40","documentation":"UptimeObserver's ensureIsMonitorApiKey throws InvalidParameter when the monitorKey query parameter is empty or missing. It is a guard that runs before any HTTP request is made, so the badge cannot be rendered without credentials. The message means: you supplied no API key at all (a separate error covers keys that are too short).","triggerScenarios":"Fetching an uptime-observer badge without a monitorKey query parameter, or with an empty string (monitorKey=''), from the fetch() method which calls ensureIsMonitorApiKey.","commonSituations":"Copying a badge snippet and deleting the ?monitorKey= part; building the badge URL programmatically and the key variable being undefined due to an unset environment variable or config placeholder.","solutions":["Add the monitorKey query parameter to the badge URL.","Copy the monitor API key from your UptimeObserver account settings.","Check the build/config that generates the badge URL to ensure the key variable is populated."],"exampleFix":"// before\nhttps://img.shields.io/uptime-observer/status/12345\n// after\nhttps://img.shields.io/uptime-observer/status/12345?monitorKey=your64charkey","handlingStrategy":"validation","validationCode":"if (!monitorKey) throw new Error('monitorKey query parameter is required')","typeGuard":"const hasKey = (v) => typeof v === 'string' && v.length > 0","tryCatchPattern":"try { await fetchBadge() } catch (e) { if (e instanceof InvalidParameter) console.error('monitorKey missing'); throw e }","preventionTips":["Keep the monitorKey in a config/env value and assert it is set before building URLs.","Never hand-edit badge URLs without re-checking query parameters.","Template badge URLs so the key is injected, never pasted piecemeal."],"tags":["bad-request","missing-parameter","api-key"],"backgroundTag":"missing-api-key","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}