fix-curator-write-with-forjego-token #235

Merged
cmo merged 2 commits from fix-curator-write-with-forjego-token into master 2026-06-25 10:33:37 +00:00
3 changed files with 20 additions and 15 deletions

View file

@ -1,3 +1,10 @@
# 6.2.1 (2026-06-26)
# Bugfixes
- Fix a bug in curator-writing when non-config tokens are used.
# 6.2.0 (2026-06-24)
# New features

View file

@ -1 +1 @@
__version__ = '6.2.0'
__version__ = '6.2.1'

View file

@ -21,9 +21,12 @@ from dump_things_service import (
HTTP_404_NOT_FOUND,
HTTP_422_UNPROCESSABLE_CONTENT, abstract_config,
)
from dump_things_service.abstract_config import check_collection, read_config, \
get_config, get_token_config_for_representation_and_collection
from dump_things_service.abstract_config import (
check_collection,
read_config,
)
from dump_things_service.api_key import api_key_header_scheme
from dump_things_service.auth import AuthenticationInfo
from dump_things_service.backends.schema_type_layer import _SchemaTypeLayer
from dump_things_service.exceptions import CurieResolutionError
from dump_things_service.instance_state import get_instance_state
@ -212,7 +215,7 @@ async def _read_curated_records(
upper_bound: int | None = 1000,
) -> LazyList | dict | None:
model_store, backend = _get_store_and_backend(collection, api_key)
model_store, backend, _ = _get_store_and_backend(collection, api_key)
if pid:
record_info = backend.get_record_by_iri(model_store.pid_to_iri(pid))
@ -246,7 +249,7 @@ async def _delete_curated_record(
api_key: str | None = None,
) -> bool:
with wrap_http_exception(Exception):
model_store, backend = _get_store_and_backend(collection, api_key)
model_store, backend, _ = _get_store_and_backend(collection, api_key)
result = backend.remove_record(model_store.pid_to_iri(pid))
if not result:
raise HTTPException(
@ -260,7 +263,7 @@ async def _delete_curated_record(
def _get_store_and_backend(
collection: str,
plain_token: str | None,
) -> tuple[_ModelStore, StorageBackend]:
) -> tuple[_ModelStore, StorageBackend, AuthenticationInfo]:
# A token is required
if plain_token is None:
@ -288,8 +291,8 @@ def _get_store_and_backend(
model_store = instance_state.curated_stores[collection]
backend = model_store.backend
if isinstance(backend, _SchemaTypeLayer):
return model_store, backend.backend
return model_store, backend
return model_store, backend.backend, auth_info
return model_store, backend, auth_info
def store_curated_record(
@ -304,7 +307,7 @@ def store_curated_record(
instance_state.validators[collection].validate(data)
pid = data.pid
model_store, backend = _get_store_and_backend(collection, api_key)
model_store, backend, auth_info = _get_store_and_backend(collection, api_key)
json_object = cleaned_json(
data.model_dump(exclude_none=True, mode='json'),
@ -318,14 +321,9 @@ def store_curated_record(
json_object,
)
_, token_config, _ = get_token_config_for_representation_and_collection(
abstract_config=get_config(),
token_representation=api_key,
collection_name=collection,
)
for audit_backend in instance_state.audit_backends[collection]:
audit_backend.add_record(
record=json_object,
committer_id=token_config.user_id,
committer_id=auth_info.user_id,
author_id=author_id,
)