danny-avila/LibreChat · error · Error

Invalid resourceType: ${resourceType}. Valid types: ${validT

Error message

Invalid resourceType: ${resourceType}. Valid types: ${validTypes.join(', ')}

What it means

validateResourceType is the central guard called by almost every public method. It rejects resourceType values that are not part of the ResourceType enum (e.g. 'agent', 'prompt'). The valid set is enumerated in the message so callers can self-correct.

Source

Thrown at packages/api/src/acl/accessControlService.ts:426

        PermissionBits.VIEW,
      );
    } catch (error) {
      if (error instanceof Error) {
        logger.error(`[PermissionService.hasPublicAccess] Error: ${error.message}`);
      }
      return false;
    }
  }

  /**
   * Validates that the resourceType is one of the supported enum values
   * @param {string} resourceType - The resource type to validate
   * @throws {Error} If resourceType is not valid
   */
  private validateResourceType(resourceType: ResourceType): void {
    const validTypes = Object.values(ResourceType);
    if (!validTypes.includes(resourceType)) {
      throw new Error(
        `Invalid resourceType: ${resourceType}. Valid types: ${validTypes.join(', ')}`,
      );
    }
  }
}

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Always pass a value imported from ResourceType, never a string literal.
  2. After upgrading librechat-data-provider, diff ResourceType and update call sites.
  3. Surfaces in nearly every ACL method — fix it once at the call site, not per method.

Example fix

// before
await svc.checkPermission({ ..., resourceType: 'agents' });

// after
import { ResourceType } from 'librechat-data-provider';
await svc.checkPermission({ ..., resourceType: ResourceType.AGENT });
Defensive patterns

Strategy: validation

Validate before calling

import { ResourceType } from 'librechat-data-provider';
const validResourceTypes = new Set(Object.values(ResourceType));
function assertResourceType(v: unknown): ResourceType {
  if (typeof v !== 'string' || !validResourceTypes.has(v as ResourceType)) {
    throw new Error(`Invalid resourceType: ${String(v)}`);
  }
  return v as ResourceType;
}

Type guard

import { ResourceType } from 'librechat-data-provider';
const isResourceType = (v: unknown): v is ResourceType =>
  typeof v === 'string' && Object.values(ResourceType).includes(v as ResourceType);

Prevention

When it happens

Trigger: Passing a resourceType that is not a ResourceType member: a typo ('a gent'), a plural ('agents'), a custom string, undefined, or a stale literal after librechat-data-provider renamed enum members.

Common situations: A new resource kind added without extending the enum; a downgrade/upgrade that changed enum casing; an external integration sending its own resource vocabulary.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/dc1e016e47b08267. Report an issue: GitHub.