Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions hindsight-api/hindsight_api/api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3485,6 +3485,9 @@ async def api_get_bank_config(bank_id: str, request_context: RequestContext = De
detail="Bank configuration API is disabled. Set HINDSIGHT_API_ENABLE_BANK_CONFIG_API=true to enable.",
)
try:
# Authenticate and set schema context for multi-tenant DB queries
await app.state.memory._authenticate_tenant(request_context)

# Get resolved config from config resolver
config_dict = await app.state.memory._config_resolver.get_bank_config(bank_id, request_context)

Expand Down Expand Up @@ -3520,6 +3523,9 @@ async def api_update_bank_config(
detail="Bank configuration API is disabled. Set HINDSIGHT_API_ENABLE_BANK_CONFIG_API=true to enable.",
)
try:
# Authenticate and set schema context for multi-tenant DB queries
await app.state.memory._authenticate_tenant(request_context)

# Update config via config resolver (validates configurable fields and permissions)
await app.state.memory._config_resolver.update_bank_config(bank_id, request.updates, request_context)

Expand Down Expand Up @@ -3557,6 +3563,9 @@ async def api_reset_bank_config(bank_id: str, request_context: RequestContext =
detail="Bank configuration API is disabled. Set HINDSIGHT_API_ENABLE_BANK_CONFIG_API=true to enable.",
)
try:
# Authenticate and set schema context for multi-tenant DB queries
await app.state.memory._authenticate_tenant(request_context)

# Reset config via config resolver
await app.state.memory._config_resolver.reset_bank_config(bank_id)

Expand Down
15 changes: 8 additions & 7 deletions hindsight-api/hindsight_api/config_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import asyncpg

from hindsight_api.config import HindsightConfig, _get_raw_config, normalize_config_dict
from hindsight_api.engine.memory_engine import fq_table
from hindsight_api.extensions.tenant import TenantExtension
from hindsight_api.models import RequestContext

Expand Down Expand Up @@ -149,8 +150,8 @@ async def _load_bank_config(self, bank_id: str) -> dict[str, Any]:
try:
async with self.pool.acquire() as conn:
row = await conn.fetchrow(
"""
SELECT config FROM banks WHERE bank_id = $1
f"""
SELECT config FROM {fq_table("banks")} WHERE bank_id = $1
""",
bank_id,
)
Expand Down Expand Up @@ -241,8 +242,8 @@ async def update_bank_config(
# Merge with existing config (JSONB || operator)
async with self.pool.acquire() as conn:
await conn.execute(
"""
UPDATE banks
f"""
UPDATE {fq_table("banks")}
SET config = config || $1::jsonb,
updated_at = now()
WHERE bank_id = $2
Expand All @@ -262,9 +263,9 @@ async def reset_bank_config(self, bank_id: str) -> None:
"""
async with self.pool.acquire() as conn:
await conn.execute(
"""
UPDATE banks
SET config = '{}'::jsonb,
f"""
UPDATE {fq_table("banks")}
SET config = '{{}}'::jsonb,
updated_at = now()
WHERE bank_id = $1
""",
Expand Down
Loading