[Bug]: Installation of hub://guardrails/detect_jailbreak fails with StrictDataclassFieldValidationError in huggingface_hub
Author: SarztakCreated Jul 21, 2026Updated Sep 27, 2026
Labelsbug
Bug Description
When attempting to install hub://guardrails/detect_jailbreak, the post-install script crashes.
The post-install script (post-install.py) fetches the Hugging Face model zhx123/ftrobertallm, which has integer values in its id2label configuration ({'0': 0, '1': 1}). Newer versions of huggingface_hub enforce strict dataclass validation and reject integer types for id2label, causing the installation to fail completely.
Steps to Reproduce
Create a Python 3.12 virtual environment with modern dependencies (
huggingface_hub >= 0.23.0).Run:
guardrails hub install hub://guardrails/detect_jailbreakObserve the post-install script error.
Expected Behavior
The package and its post-install script should complete installation without crashing on standard/recent versions of huggingface_hub and transformers.
Environment / Context
- Python Version: 3.12
- OS: Linux
- Package:
hub://guardrails/detect_jailbreak
Error Stack Trace
[== ] Running post-install setupTraceback (most recent call last):
File ".../site-packages/huggingface_hub/dataclasses.py", line 507, in _validate_union
raise TypeError(
TypeError: Field 'id2label' with value {'0': 0, '1': 1} doesn't match any type in (dict[int, str], dict[str, str], <class 'NoneType'>). Errors: Invalid key or value in dict 'id2label'; Field 'id2label' expected NoneType, got dict (value: {'0': 0, '1': 1})
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".../guardrails_grhub_detect_jailbreak/post-install.py", line 14, in <module>
pipeline("text-classification", "zhx123/ftrobertallm")
...
huggingface_hub.errors.StrictDataclassFieldValidationError: Validation error for field 'id2label':
TypeError: Field 'id2label' with value {'0': 0, '1': 1} doesn't match any type in (dict[int, str], dict[str, str], <class 'NoneType'>).
ERROR:guardrails-cli:Failed to run post install script for guardrails/detect_jailbreak
Root Cause & Suggested Solution
- Root Cause: The upstream model
zhx123/ftrobertallmused indetect_jailbreakcontains invalidid2labelformatting (0instead of"0"or"LABEL_0"), which violateshuggingface_hub's strict schema validation. - Suggested Fix: Update
post-install.pyin the validator package to use a compliant model, or pin/patchid2labelmapping prior to initializing the pipeline.
Source: guardrails-ai/guardrails