{"record":{"id":"17b356fe189603cb","repo":"can1357/oh-my-pi","slug":"invalid-service-tier-string-tier-for-family","errorCode":null,"errorMessage":"Invalid service tier \"${String(tier)}\" for family \"${String(family)}\"","messagePattern":"Invalid service tier \"(.+?)\" for family \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensibility/extensions/loader.ts","lineNumber":315,"sourceCode":"\tsetModel(model: Model): Promise<boolean> {\n\t\treturn this.runtime.setModel(model);\n\t}\n\n\tgetThinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this.runtime.getThinkingLevel();\n\t}\n\n\tsetThinkingLevel(level: ThinkingLevel, persist?: boolean): void {\n\t\tthis.runtime.setThinkingLevel(level, persist);\n\t}\n\n\tgetServiceTiers(): Readonly<ServiceTierByFamily> {\n\t\treturn { ...this.runtime.getServiceTiers() };\n\t}\n\n\tsetServiceTier(family: ServiceTierFamily, tier: ServiceTier | undefined): void {\n\t\tif (!isServiceTierFamily(family) || (tier !== undefined && !isServiceTierForFamily(family, tier))) {\n\t\t\tthrow new TypeError(`Invalid service tier \"${String(tier)}\" for family \"${String(family)}\"`);\n\t\t}\n\t\tthis.runtime.setServiceTier(family, tier);\n\t}\n\n\tgetSessionName(): string | undefined {\n\t\treturn this.runtime.getSessionName();\n\t}\n\n\tsetSessionName(name: string): Promise<void> {\n\t\treturn this.runtime.setSessionName(name);\n\t}\n\n\tregisterProvider(name: string, config: ProviderConfig): void {\n\t\tthis.runtime.registerProvider(name, config, this.extension.path);\n\t}\n\n\tunregisterProvider(name: string): void {\n\t\tthis.runtime.unregisterProvider(name, this.extension.path);","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/extensions/loader.ts#L297-L333","documentation":"setServiceTier validates its arguments before delegating to the runtime: family must be a known service-tier family and, when tier is defined, it must be a valid tier for that family. Anything else throws a TypeError reporting both the offending values.","triggerScenarios":"Calling runtime.setServiceTier(family, tier) with a misspelled family name, a tier that is not offered for that family, or tier values typed as wrong runtime values (e.g. numbers/objects stringified in the message).","commonSituations":"Hardcoded tier string with a typo ('priority' vs 'flex'); copying a tier valid for one family (e.g. OpenAI) and applying it to another; tier read from env/config that is unset so String(undefined) appears in the message.","solutions":["Use getServiceTiers() to enumerate valid families and their allowed tiers before calling setServiceTier.","Correct the family name/tier spelling against the ServiceTierFamily and ServiceTier types.","Validate the config-provided tier against the allowed set for the family before invoking the API; pass undefined to clear."],"exampleFix":"// before\nruntime.setServiceTier('openai', 'priority' as any); // may not be valid\n// after\nconst tiers = runtime.getServiceTiers();\nconst allowed = tiers['openai'];\nif (allowed && allowed.includes('priority')) runtime.setServiceTier('openai', 'priority');","handlingStrategy":"validation","validationCode":"const tiers = runtime.getServiceTiers();\nconst allowed = tiers[family];\nif (allowed && (tier === undefined || allowed.includes(tier))) {\n  runtime.setServiceTier(family, tier);\n}","typeGuard":"function isValidTierCall(f: string, t: unknown, tiers: ServiceTierByFamily): boolean {\n  const allowed = tiers[f as keyof ServiceTierByFamily];\n  return Array.isArray(allowed) && (t === undefined || (allowed as string[]).includes(t as string));\n}","tryCatchPattern":"try {\n  runtime.setServiceTier(family, tier);\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes('Invalid service tier')) {\n    logger.error('bad service tier/family', { family, tier });\n  } else throw err;\n}","preventionTips":["Query getServiceTiers() instead of hardcoding families/tiers.","Type family/tier with the ServiceTierFamily/ServiceTier unions, not strings.","Validate env/config-sourced tiers before use; unset values become 'undefined' strings.","Don't copy tiers across families — each family has its own allowed set."],"tags":["validation","extensions","service-tier"],"backgroundTag":"invalid-enum-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}