zylon-ai/private-gpt · error · ValueError

Unknown skill_or_version_ids in collection '{collection}': {

Error message

Unknown skill_or_version_ids in collection '{collection}': {', '.join(missing)}

What it means

When resolving a batch of skill/version identifiers within a collection, the repository loads matching skills and versions and computes the set difference; any requested identifiers found in neither table raise ValueError listing the unknown ids. It guarantees callers cannot silently operate on ids that belong to another collection or do not exist — an integrity/authorization-style guard for cross-collection id confusion.

Source

Thrown at private_gpt/components/skills/repositories/skill_repository.py:368

        }

        versions = {
            row.id: row
            for row in (
                await session.scalars(
                    select(SkillVersionORM)
                    .join(SkillORM, SkillVersionORM.skill_id == SkillORM.id)
                    .where(
                        SkillORM.collection == collection,
                        SkillVersionORM.id.in_(identifiers),
                    )
                )
            ).all()
        }

        missing = sorted(identifiers - skills.keys() - versions.keys())
        if missing:
            raise ValueError(
                f"Unknown skill_or_version_ids in collection '{collection}': {', '.join(missing)}"
            )

        result: list[SkillVersionEntity] = [
            _version_from_orm(row) for row in versions.values()
        ]

        for skill_id in skills:
            latest = await _latest_version_row_for_skill(session, skill_id)
            if latest:
                result.append(_version_from_orm(latest))

        return result

    async def _recover_all_latest_versions(
        self, session: AsyncSession, skill_filter: SkillFilter
    ) -> list[SkillVersionEntity]:
        latest_versions = _latest_versions_subquery()

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Re-list the collection's skills/versions and refresh the client's stored ids before retrying.
  2. Filter out unknown ids up front if partial success is acceptable: resolve against the current listing first.
  3. Verify the ids were not copied from another collection/environment; prefix/scope checks help.
  4. Handle deletion races: on this error, invalidate the cache and re-fetch the id set once.

Example fix

# before
entities = await repo.resolve_many(collection, requested_ids)
# ValueError: Unknown skill_or_version_ids ... (stale cached id)

# after
valid_ids = {s.id for s in await repo.list_skills(collection)}
entities = await repo.resolve_many(collection, [i for i in requested_ids if i in valid_ids])
Defensive patterns

Strategy: validation

Validate before calling

async def filter_known_ids(repo, collection: str, ids: list[str]) -> list[str]:
    known = {s.id for s in await repo.list_skills(collection)}
    known |= {v.id for v in await repo.list_versions_all(collection)}  # adapt to actual API
    missing = [i for i in ids if i not in known]
    if missing:
        logger.warning("Dropping unknown/stale ids: %s", missing)
    return [i for i in ids if i in known]

Try / catch

try:
    entities = await repo.resolve(collection, ids)
except ValueError as e:
    if "Unknown skill_or_version_ids" in str(e):
        ids = await refresh_ids_and_filter(ids)  # invalidate cache, re-list, retry once
        entities = await repo.resolve(collection, ids)
    else:
        raise

Prevention

When it happens

Trigger: Calling the batch resolution API (the method around skill_repository.py:368) with skill_or_version_ids containing an id that is deleted, belongs to a different collection, or is malformed (e.g. a stale id persisted by a client after the skill was removed).

Common situations: Client-side caches holding ids of since-deleted skills; copy-pasting ids between environments (dev id used against prod); a skill removed concurrently between listing and batch fetch; typos or truncated ids in requests.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/6ff7d143559efbe9. Report an issue: GitHub.