{"record":{"id":"3f6a3a4834a9da56","repo":"thingsboard/thingsboard","slug":"can-t-crate-alarm-source-without-entityid-informat","errorCode":null,"errorMessage":"Can't crate alarm source without entityId information!","messagePattern":"Can't crate alarm source without entityId information!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ui-ngx/src/app/core/http/entity.service.ts","lineNumber":968,"sourceCode":"        });\n        return dataKeys;\n      })\n    );\n  }\n\n  public createDatasourcesFromSubscriptionsInfo(subscriptionsInfo: Array<SubscriptionInfo>): Array<Datasource> {\n    const datasources = subscriptionsInfo.map(subscriptionInfo => this.createDatasourceFromSubscriptionInfo(subscriptionInfo));\n    this.utils.generateColors(datasources);\n    return datasources;\n  }\n\n  public createAlarmSourceFromSubscriptionInfo(subscriptionInfo: SubscriptionInfo): Datasource {\n    if (subscriptionInfo.entityId && subscriptionInfo.entityType) {\n      const alarmSource = this.createDatasourceFromSubscriptionInfo(subscriptionInfo);\n      this.utils.generateColors([alarmSource]);\n      return alarmSource;\n    } else {\n      throw new Error('Can\\'t crate alarm source without entityId information!');\n    }\n  }\n\n  public resolveAlias(entityAlias: EntityAlias, stateParams: StateParams): Observable<AliasInfo> {\n    const filter = entityAlias.filter;\n    return this.resolveAliasFilter(filter, stateParams).pipe(\n      mergeMap((result) => {\n        const aliasInfo: AliasInfo = {\n          alias: entityAlias.alias,\n          entityFilter: result.entityFilter,\n          stateEntity: result.stateEntity,\n          entityParamName: result.entityParamName,\n          resolveMultiple: filter.resolveMultiple\n        };\n        aliasInfo.currentEntity = null;\n        if (!aliasInfo.resolveMultiple && aliasInfo.entityFilter) {\n          let currentEntity: EntityInfo = null;\n          if (result.stateEntity && aliasInfo.entityFilter.type === AliasFilterType.singleEntity) {","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/thingsboard/thingsboard/blob/45c30e83fa57356840d5f25d894002d94222d524/ui-ngx/src/app/core/http/entity.service.ts#L950-L986","documentation":"Thrown by EntityService.createAlarmSourceFromSubscriptionInfo when building an alarm datasource from a subscription info that lacks entityId or entityType. Alarm widgets query alarms for one concrete entity, so the datasource is impossible to construct without both fields. The message contains a typo ('crate') but the condition is clear: falsy subscriptionInfo.entityId || falsy subscriptionInfo.entityType.","triggerScenarios":"Calling createAlarmSourceFromSubscriptionInfo with a SubscriptionInfo where entityId or entityType is undefined — e.g. a widget/subscription created from an alias resolving to zero entities, a state entity with no state param, or a manually built subscriptionInfo object missing those keys.","commonSituations":"Alarm widget on a dashboard whose entity alias is unresolved (filter matches nothing or depends on an absent state parameter); importing a dashboard whose alias references a deleted entity; custom widget code calling the service without populating entityId.","solutions":["Ensure the widget's target entity resolves: check the alias/filter behind the subscription actually yields an entity (open the alias in the dashboard editor).","If the widget depends on entity from state, verify the state params (entityId/entityName) are set when the dashboard opens.","When calling the API directly, populate subscriptionInfo.entityId and subscriptionInfo.entityType before invoking.","Wrap dashboard-level usage so an unresolved alias shows an 'entity not found' state instead of crashing the subscription pipeline."],"exampleFix":"// before\nconst src = this.entityService.createAlarmSourceFromSubscriptionInfo({ type: 'entity' }); // no entityId -> throws\n\n// after\nconst src = this.entityService.createAlarmSourceFromSubscriptionInfo({\n  type: 'entity',\n  entityId: 'fd7f0a10-...',\n  entityType: EntityType.DEVICE\n});","handlingStrategy":"type-guard","validationCode":"if (!subscriptionInfo.entityId || !subscriptionInfo.entityType) {\n  // show 'no entity resolved' state instead of building an alarm source\n  return this.createDefaultAlarmSource();\n}","typeGuard":"function hasEntityRef(s: SubscriptionInfo): s is SubscriptionInfo & { entityId: string; entityType: EntityType } {\n  return typeof s.entityId === 'string' && s.entityId.length > 0 && typeof s.entityType === 'string';\n}","tryCatchPattern":"try { alarmSource = this.entityService.createAlarmSourceFromSubscriptionInfo(info); } catch (e) { if (e.message.includes('alarm source')) { this.showAlias unresolved warning; } else throw e; }","preventionTips":["Check alias resolution before creating alarm subscriptions.","Populate entityId/entityType when constructing SubscriptionInfo programmatically.","Design dashboards so alarm widgets show an empty state when no entity resolves."],"tags":["angular","thingsboard-ui","widget","subscription","validation"],"backgroundTag":null,"analyzedSha":"45c30e83fa57356840d5f25d894002d94222d524","analyzedAt":"2026-08-14T11:45:36.599Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}