{"record":{"id":"3aa7af0603c3727f","repo":"ruvnet/ruflo","slug":"fleet-fleetid-not-found","errorCode":null,"errorMessage":"Fleet ${fleetId} not found","messagePattern":"Fleet (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-iot-cognitum/src/domain/services/fleet-topology-service.ts","lineNumber":81,"sourceCode":"      name: options.name,\n      description: options.description ?? '',\n      zoneId: options.zoneId,\n      deviceIds: [],\n      topology: options.topology ?? 'star',\n      firmwarePolicy: { ...DEFAULT_FIRMWARE_POLICY, ...options.firmwarePolicy },\n      telemetryPolicy: { ...DEFAULT_TELEMETRY_POLICY, ...options.telemetryPolicy },\n      healthThresholds: { ...DEFAULT_HEALTH_THRESHOLDS, ...options.healthThresholds },\n      createdAt: new Date(),\n      updatedAt: new Date(),\n    };\n\n    await this.repo.save(fleet);\n    return fleet;\n  }\n\n  async getFleet(fleetId: string): Promise<DeviceFleet> {\n    const fleet = await this.repo.findById(fleetId);\n    if (!fleet) throw new Error(`Fleet ${fleetId} not found`);\n    return fleet;\n  }\n\n  async listFleets(): Promise<FleetSummary[]> {\n    const fleets = await this.repo.findAll();\n    return fleets.map((f) => ({\n      fleetId: f.fleetId,\n      name: f.name,\n      zoneId: f.zoneId,\n      deviceCount: f.deviceIds.length,\n      topology: f.topology,\n      createdAt: f.createdAt,\n    }));\n  }\n\n  async addDeviceToFleet(fleetId: string, deviceId: string): Promise<DeviceFleet> {\n    const fleet = await this.getFleet(fleetId);\n    if (fleet.deviceIds.includes(deviceId)) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-iot-cognitum/src/domain/services/fleet-topology-service.ts#L63-L99","documentation":"The central fleet lookup: getFleet throws when repo.findById returns null, and most fleet operations (updateFirmwarePolicy, getFleetDeviceCount, ...) delegate to it, so essentially any reference to an unknown fleetId surfaces here.","triggerScenarios":"Calling getFleet, updateFirmwarePolicy, or getFleetDeviceCount with a fleetId that was never created, was deleted, or lives in a different repository or persistence scope.","commonSituations":"Stale fleet IDs after an environment reset or store wipe; hand-typed IDs with typos; fleets created in an in-memory repo during tests while the caller reads a persisted repo.","solutions":["Confirm the ID via listFleets and use the exact fleetId returned","Create the fleet first if it should exist","Check for concurrent deletion or a repo-backend mismatch (in-memory vs persisted) between processes"],"exampleFix":"// before\nawait fleetService.updateFirmwarePolicy('flt-99', { channel: 'stable' }); // unknown ID\n\n// after\nconst fleets = await fleetService.listFleets();\nconst fleet = fleets.find((f) => f.name === 'Factory Floor');\nif (!fleet) throw new Error('fleet missing; create it first');\nawait fleetService.updateFirmwarePolicy(fleet.fleetId, { channel: 'stable' });","handlingStrategy":"validation","validationCode":"const ids = new Set((await fleetService.listFleets()).map((f) => f.fleetId));\nif (!ids.has(fleetId)) {\n  throw new Error(`unknown fleet ${fleetId}; known: ${[...ids].join(', ')}`);\n}\nawait fleetService.updateFirmwarePolicy(fleetId, policy);","typeGuard":null,"tryCatchPattern":"try {\n  await fleetService.updateFirmwarePolicy(fleetId, policy);\n} catch (e) {\n  if (e instanceof Error && e.message === `Fleet ${fleetId} not found`) {\n    // re-list fleets; create the fleet or prompt for the correct ID\n  } else throw e;\n}","preventionTips":["Pass fleet IDs obtained from listFleets or createFleet, never hand-typed","Persist fleet IDs in the config that consumes them","Use one repository backend consistently across all processes"],"tags":["iot","fleet","entity-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}