passbolt/passbolt_api · error · Cake\Http\Exception\BadRequestException

The resource type ` ` has not map for scim entry model

Error message

The resource type `%s` has not map for scim entry model

What it means

After ScimResources::isValid() passes, fetchResources() additionally requires an entry in ScimEntry::MODEL_MAP so the resource type can be resolved to a foreign model ('users'/'groups'). A type that passes validity but lacks a mapping indicates an internal inconsistency (a registered SCIM resource type without a database-backed entry model) and throws BadRequestException. With the current MODEL_MAP (Users/Groups only) this is effectively dead defensive code, but it guards future additions.

Solutions

  1. Add a mapping in ScimEntry::MODEL_MAP for the new resource type, pointing to its foreign model constant.
  2. Ensure plugin versions are consistent — redeploy the full PassboltEe/Scim plugin so ScimResources and ScimEntry agree.
  3. If the type isn't intended to be supported, fix the caller to use only Users/Groups.

Example fix

// before (ScimEntry.php)
public const MODEL_MAP = [
    ScimResources::USERS => self::FOREIGN_MODEL_USERS,
];
// after
public const MODEL_MAP = [
    ScimResources::USERS => self::FOREIGN_MODEL_USERS,
    ScimResources::GROUPS => self::FOREIGN_MODEL_GROUPS,
];
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Object.keys(ScimEntry::MODEL_MAP).contains($resourceType)) { /* reject before calling */ }

Try / catch

try {
  $response = (new ListResponse())->fetchResources($resourceType);
} catch (BadRequestException $e) {
  Log::error('SCIM resource type lacks MODEL_MAP entry: ' . $resourceType);
}

Prevention

When it happens

Trigger: GET /scim/v2/<type> where <type> is recognized by ScimResources but absent from ScimEntry::MODEL_MAP — only possible if ScimResources is extended (e.g. a new const like SCIM_RESOURCES_EMAILS added to isValid() without a MODEL_MAP entry).

Common situations: Custom development extending the SCIM plugin with new resource types; a plugin version mismatch where ScimResources knows a type the entry model map doesn't (mixed plugin/core versions after partial deploy).

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/2121e78a471414d0. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/Scim/src/Utility/Object/ListResponse.php:90

     *
     * @param string $resourceType
     * @param int|null $startIndex
     * @param int|null $count
     * @param string|null $filter
     * @return $this
     * @throws \Exception
     */
    public function fetchResources(
        string $resourceType,
        ?int $startIndex = null,
        ?int $count = null,
        ?string $filter = null,
    ) {
        if (!ScimResources::isValid($resourceType)) {
            throw new BadRequestException(sprintf('The resource type `%s` is not valid', $resourceType));
        }
        if (!isset(ScimEntry::MODEL_MAP[$resourceType])) {
            throw new BadRequestException(
                sprintf('The resource type `%s` has not map for scim entry model', $resourceType)
            );
        }

        if ($startIndex !== null && $startIndex > 0) {
            $this->startIndex = $startIndex;
        }
        if ($count !== null && $count > 0) {
            $this->itemsPerPage = $count;
        }

        /** @var \Passbolt\Scim\Model\Table\ScimEntriesTable $scimEntriesTable */
        $scimEntriesTable = $this->fetchTable('Passbolt/Scim.ScimEntries');
        $conditions = [
            $scimEntriesTable->aliasField('foreign_model') => ScimEntry::MODEL_MAP[$resourceType],
        ];
        if ($filter !== null) {
            //@todo: tmilos/scim-filter-parser should be used if more filters are needed

View on GitHub (pinned to 31c1bbc10f)