Skip to content

FIX: Register created converters and targets only after the response is built - #2964

Merged
varunj-msft merged 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/10765-Atomic-Component-Create
Oct 6, 2026
Merged

varunj-msft merged 1 commit into
microsoft:mainfrom
varunj-msft:varunj-msft/10765-Atomic-Component-Create

Conversation

@varunj-msft

@varunj-msft varunj-msft commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Split out of #2959. ConverterService.create_converter_async and TargetService.create_target_async registered the new object first and mapped it to the API response afterwards. If mapping failed (identifier generation, capabilities, nested targets, DTO validation), the request failed but the object stayed registered, and the converter's uploaded files were left behind. For example, TextTarget with custom_configuration={} returned 500 and stayed registered, so retrying with the same name failed with "already exists".

Create is now atomic:

  • Order: both services construct the object with the registry (create_instance), build the response, and register it last. The mappers read only the object and class metadata, never the instance registry.
  • Name check: as before, the converter flow checks the name again after its uploads (an await), so a request that lost the name to a concurrent create never runs its constructor. Nothing between that check and register awaits.
  • Cleanup: any failure, including registration, removes the request's uploaded files, and nothing is registered.

Coordination:

Tests and Documentation

  • Converter tests (tests/unit/backend/test_converter_service.py):
    • a mapping failure leaves nothing registered and no uploads;
    • a name taken during the upload stops construction;
    • a registration failure removes the upload.
  • Target tests (tests/unit/backend/test_target_service.py): a mapping failure leaves nothing registered.
  • Both mapping-failure tests fail on main.
  • python -m pytest tests/unit/backend -n 4 — 1713 passed, 4 skipped.
  • ruff format / ruff check — passed; ty check pyrit/ — no new diagnostics; pre-commit hooks pass.
  • build_and_test workflow run on the fork at c298f5c: pre-commit on ubuntu/windows/macOS and make unit-test-junit on ubuntu/windows/macOS x Python 3.11-3.14 x dev/dev_all — all 35 jobs passed.
  • Live backend: TextTarget with custom_configuration={} still returns 500 on this branch (FIX: Accept only supported external inputs when building components #2959 makes it a 400), but the target is not registered and the same name can be created right after.
  • No docs changed.

…is built

The backend registered a new converter or target before mapping it to the
API response, so a mapping failure left the object registered and, for
converters, left its uploaded files behind. Create now constructs the
object, builds the response, and registers it last. Any failure removes
the request's uploads and leaves nothing registered.
@varunj-msft
varunj-msft added this pull request to the merge queue Oct 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 6, 2026
@varunj-msft
varunj-msft added this pull request to the merge queue Oct 6, 2026
Merged via the queue into microsoft:main with commit dbfe688 Oct 6, 2026
99 of 102 checks passed
@varunj-msft
varunj-msft deleted the varunj-msft/10765-Atomic-Component-Create branch October 6, 2026 03:00
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.

2 participants