Repository navigation
Conversation
Message.workflow_run and WorkflowAppLog.workflow_run built their own sessionmaker from the global engine, but nothing reads them: the app log endpoints serialize DTOs from WorkflowAppLogQueryRepository instead. Remove both, the db import in models/model.py they left unused, and the test patch of that import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Provider.credential and ProviderModel.credential were cached properties that opened their own session. ProviderManager already preloads these rows in batches, so the lookup only served as a hidden fallback. Provider now reads a credential attached by the caller and raises when it was not attached. ProviderModel's accessors had no readers and are removed; the loaded credential is passed to the cache entry directly. The IntegrityError branch of _init_trial_provider_records returned records that bypassed the batch load, so it now attaches their credential too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the heads-up, @xiaoyuCR7. My earlier comment on #45166 was a proposed scope and test plan; I have not started a competing implementation. Your call-site audit covers the same |
|
Hey! I tested your changes locally and added two additional regression tests in They cover:
The full provider manager test file passes locally (57 passed). Would these additional tests be useful for your PR? I'd be happy to contribute them. |
Fixes #45166.
_resolve_workflow_app_tenant_idis left to #43112, which alreadyhandles it and has auto-merge enabled, so this PR does not touch it.
Summary
Message.workflow_runandWorkflowAppLog.workflow_runeach build their ownsessionmakerfrom the global engine. I found no callers, so this PR removesthem instead of adding a
sessionparameter.WorkflowAppLogQueryRepository, not these ORM properties.log.workflow_runaccess I found, in the e2e tests, reads that DTO.workflow_runfrom aMessage.dbimport inmodels/model.pybecame unused, so it is removed, alongwith the
models.model.dbpatch intest_human_input_form.py.Provider credentials
Provider.credentialandProviderModel.credentialwerecached_propertyaccessors that opened their own session.
ProviderManageralready preloads theserows in batches, so that lookup was only a hidden fallback.
Provider.credentialnow reads a value attached by the caller throughattach_credentialand never queries. It raisesRuntimeErrorif the credentialwas not attached, so a missing load cannot look like an unset credential.
ProviderModel.credential,credential_nameandencrypted_confighad noreaders and are removed. The loaded row is passed to
_ProviderModelCacheEntry.from_recorddirectly._init_trial_provider_recordscould return an existing record from itsIntegrityErrorbranch without the batch load, so that branch attaches thecredential too. This keeps the previous behavior for such a record.
Behavior change to review: reading a credential on a
Providerloaded outsideProviderManagerwithout attaching now raises instead of querying. I found nosuch reader in production code.
@GYJ99 I saw your comment on the same two accessors after preparing this
change. I'm opening it because the audit suggests they can be deleted. Happy to coordinate if you already have work in progress.
Testing
Run locally on Windows with Python 3.13, without the
vdb-alldependency group:pytestontests/unit_tests/models,core/entities,core/ops,core/app/llm,core/test_provider_manager.py, and the human input and workflow log tests:1061 passed, 1 error. The error is a Windows temp file
PermissionErrorintest_trace_entity.py, and it also occurs on the unmodified base commit.IntegrityErrorbranch makes itsregression test fail with the expected
RuntimeError.pyrefly checkon the four changed source files: 0 diagnostics.lint-imports: 76 contracts kept, 0 broken.ruff formatandruff checkpass on the changed files.Not verified:
make lint && make type-checkwere not run.--no-covand a stub forpython-magic, because importinglibmagic segfaults on this machine. CI is awaiting maintainer approval.
Screenshots
N/A, no UI change.
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsFrom Claude Code
🤖 Generated with Claude Code