thingsboard/thingsboard · error · Error

Can't crate alarm source without entityId information!

Error message

Can't crate alarm source without entityId information!

What it means

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.

Source

Thrown at ui-ngx/src/app/core/http/entity.service.ts:968

        });
        return dataKeys;
      })
    );
  }

  public createDatasourcesFromSubscriptionsInfo(subscriptionsInfo: Array<SubscriptionInfo>): Array<Datasource> {
    const datasources = subscriptionsInfo.map(subscriptionInfo => this.createDatasourceFromSubscriptionInfo(subscriptionInfo));
    this.utils.generateColors(datasources);
    return datasources;
  }

  public createAlarmSourceFromSubscriptionInfo(subscriptionInfo: SubscriptionInfo): Datasource {
    if (subscriptionInfo.entityId && subscriptionInfo.entityType) {
      const alarmSource = this.createDatasourceFromSubscriptionInfo(subscriptionInfo);
      this.utils.generateColors([alarmSource]);
      return alarmSource;
    } else {
      throw new Error('Can\'t crate alarm source without entityId information!');
    }
  }

  public resolveAlias(entityAlias: EntityAlias, stateParams: StateParams): Observable<AliasInfo> {
    const filter = entityAlias.filter;
    return this.resolveAliasFilter(filter, stateParams).pipe(
      mergeMap((result) => {
        const aliasInfo: AliasInfo = {
          alias: entityAlias.alias,
          entityFilter: result.entityFilter,
          stateEntity: result.stateEntity,
          entityParamName: result.entityParamName,
          resolveMultiple: filter.resolveMultiple
        };
        aliasInfo.currentEntity = null;
        if (!aliasInfo.resolveMultiple && aliasInfo.entityFilter) {
          let currentEntity: EntityInfo = null;
          if (result.stateEntity && aliasInfo.entityFilter.type === AliasFilterType.singleEntity) {

View on GitHub (pinned to 45c30e83fa)

Solutions

  1. 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).
  2. If the widget depends on entity from state, verify the state params (entityId/entityName) are set when the dashboard opens.
  3. When calling the API directly, populate subscriptionInfo.entityId and subscriptionInfo.entityType before invoking.
  4. Wrap dashboard-level usage so an unresolved alias shows an 'entity not found' state instead of crashing the subscription pipeline.

Example fix

// before
const src = this.entityService.createAlarmSourceFromSubscriptionInfo({ type: 'entity' }); // no entityId -> throws

// after
const src = this.entityService.createAlarmSourceFromSubscriptionInfo({
  type: 'entity',
  entityId: 'fd7f0a10-...',
  entityType: EntityType.DEVICE
});
Defensive patterns

Strategy: type-guard

Validate before calling

if (!subscriptionInfo.entityId || !subscriptionInfo.entityType) {
  // show 'no entity resolved' state instead of building an alarm source
  return this.createDefaultAlarmSource();
}

Type guard

function hasEntityRef(s: SubscriptionInfo): s is SubscriptionInfo & { entityId: string; entityType: EntityType } {
  return typeof s.entityId === 'string' && s.entityId.length > 0 && typeof s.entityType === 'string';
}

Try / catch

try { alarmSource = this.entityService.createAlarmSourceFromSubscriptionInfo(info); } catch (e) { if (e.message.includes('alarm source')) { this.showAlias unresolved warning; } else throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of thingsboard/thingsboard@45c30e83fa (2026-08-14). Data as JSON: /api/errors/3f6a3a4834a9da56. Report an issue: GitHub.