Skip to content

fix(hooks): improve agent-scoped hook error messaging#1224

Open
bclermont wants to merge 3 commits into
nextlevelbuilder:devfrom
bclermont:fix/agent-scope-hook-tenant-id-clean
Open

fix(hooks): improve agent-scoped hook error messaging#1224
bclermont wants to merge 3 commits into
nextlevelbuilder:devfrom
bclermont:fix/agent-scope-hook-tenant-id-clean

Conversation

@bclermont

Copy link
Copy Markdown
Contributor

Summary

Agent-scoped hooks cannot be created in the master/system tenant by design (for tenant isolation). This PR improves the error messaging to clearly explain this requirement.

Changes

  • Backend: Auto-fill tenant_id for both tenant and agent scopes
  • Backend: Improve error message to guide users to create a workspace tenant
  • Frontend: Auto-fill tenant_id from auth context for agent scope
  • Frontend: Allow empty string in tenant_id schema validation
  • Frontend: Remove tenant_id requirement validation (let backend enforce with clear message)

Design Discussion

This PR assumes that agent-scoped hooks should NOT be allowed in the master/system tenant (by design, for tenant isolation). Is this the intended behavior?

🤖 Generated with Claude Code

Bruno Clermont and others added 3 commits June 12, 2026 23:00
When creating an agent-scoped hook without an explicit tenant_id, the
config may be initialized with SentinelTenantID. The previous logic only
checked for uuid.Nil when deciding whether to fill TenantID from context,
causing the sentinel value to be passed to validation, which then fails
with 'agent scope requires a real tenant_id'.

Fix: Check for both uuid.Nil AND SentinelTenantID when deciding to fill
TenantID from the request context.

Fixes: agent-scoped hooks now properly inherit tenant context from the
request connection, matching behavior of tenant-scoped hooks.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Frontend: Allow empty string in tenant_id schema validation (Zod)
- Frontend: Validate tenant_id requirement only for agent scope (superRefine)
- Frontend: Auto-fill tenant_id from auth context on agent-scope hook submit
- Frontend: Fix Save button onClick to properly execute form submission
- Dev: Add docker-compose.dev.yml for SQLite-based local dev (no PG needed)
- Dev: Add DEV.md guide for local iteration (Go+Vite or Docker)

This completes the fix for "agent scope requires a real tenant_id" error.
Agent-scoped hooks now auto-populate tenant_id from user's auth context,
never requiring manual entry. Save button is responsive in form dialog.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Agent-scoped hooks cannot be created in the master/system tenant.
Updated error message to clearly indicate this requirement and
guide users to create a workspace tenant.

Changes:
- Backend: Auto-fill tenant_id for both tenant and agent scopes
- Backend: Improve error message for agent scope validation
- Frontend: Auto-fill tenant_id from auth context for agent scope
- Frontend: Allow empty string in tenant_id schema validation
- Frontend: Validate tenant_id requirement only for agent scope

The core issue: agent-scoped hooks require a real workspace tenant,
not the master/system tenant where most users operate. This is by design
to enforce proper tenant isolation.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@bclermont bclermont force-pushed the fix/agent-scope-hook-tenant-id-clean branch from edf0a56 to efe7155 Compare June 13, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant