fix: reject providers missing adapter type - #9404
Open
EterUltimate wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9399.
Evidence
POST /api/v1/provider-sources/providersending inKeyError('type')atastrbot/core/provider/manager.pyinsideload_provider.ProviderManager.create_providerappends the new provider toconfig["provider"], saves config, and only then callsload_provider; a missing mergedtypetherefore both raises and leaves a bad provider persisted.astrbot/dashboard/api/providers.py->ProviderConfigService.create_provider->ProviderManager.create_provider->load_provider.Changes
typeduringload_providerinstead of raisingKeyError.PersonaManagerannotation import behindTYPE_CHECKINGto avoid the circular import exposed by the new core regression test.Merge plan
ChatUIbasic retry provider selection) and already has green checks. Merge fix: use current provider selection when regenerating chat message #9402 for that issue.Verification
uv run ruff check .uv run ruff format --check .uv run pytest tests/unit/test_provider_manager_config_validation.py tests/test_fastapi_v1_dashboard.py -q-> 74 passeduv run pytest tests/unit/test_provider_manager_config_validation.py tests/test_fastapi_v1_dashboard.py::test_v1_safe_provider_routes_accept_slash_ids tests/test_chat_route.py -q-> 12 passeduv run astrbot --helpcd dashboard && bunx pnpm@10.28.2 install --frozen-lockfilecd dashboard && bunx pnpm@10.28.2 run buildFull local Windows pytest was also run with
uv run pytest --cov=astrbot tests/ -q: 1841 passed, 28 failed. The failures are existing Windows path/newline/sandbox/file-uri/local-shell cases outside the provider files touched here; targeted provider/API tests passed.tests/test_code_quality_typing.pyis not present on currentorigin/master, so it could not be run.Summary by Sourcery
Validate provider configurations for a valid adapter type before persisting them and ensure loading skips invalid providers instead of raising errors.
Bug Fixes:
Enhancements:
Tests: