chore(api): remove redundant str() on StringUUID ids (#43061)

This commit is contained in:
Denis Ermakov
2026-09-29 02:00:16 +00:00
committed by GitHub
parent 357f697b16
commit 18fea7ff0d
8 changed files with 20 additions and 26 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ class AgentBehindApp(_ParamLocator):
binding = agent_binding(tenant_id, _required(path_args, self.param))
if binding is None or binding.scope == AgentScope.WORKFLOW_ONLY:
return None
return ResourceIdentity(self.scope, str(binding.id))
return ResourceIdentity(self.scope, binding.id)
def owner_id(self, tenant_id: str, identity: ResourceIdentity) -> str | None:
return None
+1 -1
View File
@@ -67,7 +67,7 @@ def _mapping(part: FileStorage, caller: Any) -> FileMapping:
uploaded = upload(part, caller)
return {
"transfer_method": FileTransferMethod.LOCAL_FILE,
"upload_file_id": str(uploaded.id),
"upload_file_id": uploaded.id,
"type": standardize_file_type(extension="." + uploaded.extension, mime_type=uploaded.mime_type),
}
@@ -21,17 +21,16 @@ from models.model import ApiToken, DatasetApiTokenBinding
def get_bound_dataset_ids(session: Session, api_token_id: str) -> set[str]:
"""Return the dataset ids a key is scoped to (empty set means unrestricted)."""
return {
str(dataset_id)
for dataset_id in session.scalars(
return set(
session.scalars(
select(DatasetApiTokenBinding.dataset_id).where(DatasetApiTokenBinding.api_token_id == api_token_id)
).all()
}
)
def list_bindings_by_token(session: Session, token_ids: Iterable[str]) -> dict[str, list[str]]:
"""Group bound dataset ids by api token id for the given tokens."""
ids = [str(token_id) for token_id in token_ids]
ids = list(token_ids)
bindings_by_token: dict[str, list[str]] = {}
if not ids:
return bindings_by_token
@@ -49,12 +48,9 @@ def find_unknown_dataset_ids(session: Session, dataset_ids: list[str], tenant_id
"""Return the dataset ids that do not belong to the tenant (preserving order)."""
if not dataset_ids:
return []
existing = {
str(dataset_id)
for dataset_id in session.scalars(
select(Dataset.id).where(Dataset.id.in_(dataset_ids), Dataset.tenant_id == tenant_id)
).all()
}
existing = set(
session.scalars(select(Dataset.id).where(Dataset.id.in_(dataset_ids), Dataset.tenant_id == tenant_id)).all()
)
return [dataset_id for dataset_id in dataset_ids if dataset_id not in existing]
@@ -76,7 +72,7 @@ def delete_keys_scoped_only_to(session: Session, dataset_id: str) -> list[str]:
Must run before the dataset row is deleted (so the bindings still exist).
Returns the deleted api_token ids; the caller controls the transaction.
"""
orphan_ids = [str(token_id) for token_id in session.scalars(token_ids_scoped_only_to(dataset_id)).all()]
orphan_ids = list(session.scalars(token_ids_scoped_only_to(dataset_id)).all())
if orphan_ids:
session.execute(delete(ApiToken).where(ApiToken.id.in_(orphan_ids)))
return orphan_ids
@@ -59,7 +59,7 @@ class SQLAlchemyOAuthDeviceTokenRepository:
)
session.add(record)
session.flush()
token_id = str(record.id)
token_id = record.id
session.commit()
rotation = OAuthDeviceTokenRotation(
@@ -150,7 +150,7 @@ class SQLAlchemyOAuthDeviceTokenRepository:
total=total,
items=tuple(
OAuthDeviceSession(
id=str(record.id),
id=record.id,
prefix=record.prefix,
client_id=record.client_id,
device_label=record.device_label,
+1 -1
View File
@@ -556,7 +556,7 @@ class AppDslService:
account.id,
scene=RBACPermission.AGENT_IMPORT_EXPORT_DSL,
resource_type=RBACResourceScope.AGENT if binding is not None else None,
resource_id=str(binding.id) if binding is not None else None,
resource_id=binding.id if binding is not None else None,
)
if not allowed:
raise NoPermissionError("Agent DSL import permission is required to import an Agent App")
+5 -7
View File
@@ -303,13 +303,11 @@ class MessageService:
FeedbackCreatedEvent(
context=TelemetryContext(tenant_id=app_model.tenant_id),
payload={
"message_id": str(message.id),
"app_id": str(app_model.id) if app_model.id is not None else None,
"conversation_id": (
str(message.conversation_id) if message.conversation_id is not None else None
),
"from_end_user_id": str(user.id) if isinstance(user, EndUser) and user.id is not None else None,
"from_account_id": str(user.id) if isinstance(user, Account) and user.id is not None else None,
"message_id": message.id,
"app_id": app_model.id,
"conversation_id": message.conversation_id,
"from_end_user_id": user.id if isinstance(user, EndUser) else None,
"from_account_id": user.id if isinstance(user, Account) else None,
"rating": rating.value if rating else None,
"from_source": (
FeedbackFromSource.USER if isinstance(user, EndUser) else FeedbackFromSource.ADMIN
+1 -1
View File
@@ -37,4 +37,4 @@ class RBACResourceService:
dataset_id = session.scalar(
select(Dataset.id).where(Dataset.pipeline_id == pipeline_id, Dataset.tenant_id == tenant_id)
)
return None if dataset_id is None else str(dataset_id)
return dataset_id
@@ -53,7 +53,7 @@ class _WhitelistResourceKind[ItemT]:
)
if last_id:
stmt = stmt.where(self.model.id > last_id)
ids = [str(resource_id) for resource_id in db.session().scalars(stmt).all()]
ids = list(db.session().scalars(stmt).all())
if not ids:
return
yield ids