Skip to content

FIX Coerce enum parameters for direct target creation#2196

Open
romanlutz wants to merge 5 commits into
microsoft:mainfrom
romanlutz:romanlutz-target-enum-coercion-clean
Open

FIX Coerce enum parameters for direct target creation#2196
romanlutz wants to merge 5 commits into
microsoft:mainfrom
romanlutz:romanlutz-target-enum-coercion-clean

Conversation

@romanlutz

@romanlutz romanlutz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Backend target creation could bypass registry coercion for classes that forward base configuration through **kwargs, leaving enum-valued API parameters as raw strings. The service also duplicated registry metadata lookup and coercion logic.

This change keeps enum and optional-scalar coercion in the shared Parameter contract, makes constructor derivation follow explicitly forwarded parent constructors in MRO order, and routes all backend target construction through TargetRegistry.create_instance. OpenAI target constructors declare their forwarding behavior, so base parameters such as endpoint, model_name, and api_key become first-class registry metadata while strict unknown-parameter rejection remains intact. Open-ended keyword bags that do not forward to a parent are not treated as inherited constructor parameters.

Tests and Documentation

  • Added coverage for enum and optional-enum coercion, forwarded constructor metadata/coercion, strict unknown-parameter rejection, target registration, and backend registry delegation.
  • Registry, target-service, and constructor-contract suite: 424 passed.
  • Parameter model suite: 88 passed.
  • Changed-file pre-commit hooks passed, including Ruff and ty type checking.
  • Documentation: N/A; this fixes internal construction and coercion behavior without changing the public API shape.
  • JupyText: N/A.

Copilot AI added 2 commits July 11, 2026 20:47
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 52e240e9-42d4-4c91-8608-6e14d5749576
Comment thread pyrit/backend/services/target_service.py Outdated
Copilot AI and others added 3 commits July 15, 2026 12:11
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 52e240e9-42d4-4c91-8608-6e14d5749576
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 52e240e9-42d4-4c91-8608-6e14d5749576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants