mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-31 16:46:07 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22de4b14ee |
@@ -67,7 +67,10 @@ def _suspend_postgres_rls(
|
||||
states: dict[str, tuple[bool, bool]] = {}
|
||||
for table_name in table_names:
|
||||
row = conn.execute(
|
||||
sa.text('SELECT relrowsecurity, relforcerowsecurity FROM pg_class WHERE oid = to_regclass(:table_name)'),
|
||||
sa.text(
|
||||
'SELECT relrowsecurity, relforcerowsecurity '
|
||||
'FROM pg_class WHERE oid = to_regclass(:table_name)'
|
||||
),
|
||||
{'table_name': table_name},
|
||||
).one()
|
||||
enabled, forced = bool(row.relrowsecurity), bool(row.relforcerowsecurity)
|
||||
@@ -138,11 +141,18 @@ def upgrade() -> None:
|
||||
if table_name == 'workspaces':
|
||||
continue
|
||||
table = sa.Table(table_name, metadata, autoload_with=conn, extend_existing=True)
|
||||
conn.execute(table.update().where(table.c.workspace_uuid == old_uuid).values(workspace_uuid=canonical_uuid))
|
||||
conn.execute(
|
||||
table.update()
|
||||
.where(table.c.workspace_uuid == old_uuid)
|
||||
.values(workspace_uuid=canonical_uuid)
|
||||
)
|
||||
|
||||
if 'metadata' in table_names:
|
||||
conn.execute(
|
||||
sa.text('UPDATE metadata SET value = :canonical_uuid WHERE key = :key AND value = :old_uuid'),
|
||||
sa.text(
|
||||
'UPDATE metadata SET value = :canonical_uuid '
|
||||
'WHERE key = :key AND value = :old_uuid'
|
||||
),
|
||||
{
|
||||
'canonical_uuid': canonical_uuid,
|
||||
'key': _OSS_WORKSPACE_METADATA_KEY,
|
||||
|
||||
@@ -12,5 +12,5 @@ def workspace_identity(execution_context: WorkspaceExecutionContext) -> dict[str
|
||||
"""Build the canonical telemetry identity for one Workspace execution."""
|
||||
workspace_uuid = execution_context.workspace_uuid.strip()
|
||||
if not workspace_uuid:
|
||||
raise ValueError('Telemetry execution Workspace UUID is empty')
|
||||
return {'workspace_uuid': workspace_uuid}
|
||||
raise ValueError("Telemetry execution Workspace UUID is empty")
|
||||
return {"workspace_uuid": workspace_uuid}
|
||||
|
||||
@@ -3,15 +3,15 @@ from __future__ import annotations
|
||||
import uuid
|
||||
|
||||
|
||||
_INSTANCE_PREFIX = 'instance_'
|
||||
_WORKSPACE_IDENTITY_NAMESPACE = uuid.UUID('8ea04f29-8528-4cc3-bb28-30a838c89d76')
|
||||
_INSTANCE_PREFIX = "instance_"
|
||||
_WORKSPACE_IDENTITY_NAMESPACE = uuid.UUID("8ea04f29-8528-4cc3-bb28-30a838c89d76")
|
||||
|
||||
|
||||
def workspace_uuid_from_instance_id(instance_id: str) -> str:
|
||||
"""Return the stable OSS Workspace UUID for a persisted instance identity."""
|
||||
value = instance_id.strip()
|
||||
if not value:
|
||||
raise ValueError('LangBot instance identity is empty')
|
||||
raise ValueError("LangBot instance identity is empty")
|
||||
|
||||
candidate = value[len(_INSTANCE_PREFIX) :] if value.startswith(_INSTANCE_PREFIX) else value
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user