Compare commits

...

2 Commits

Author SHA1 Message Date
core-be 8dc9549dbb fix(handlers): add missing log import to container_files.go
log.Printf is called at line 35 but "log" was not in the import block,
causing a compile failure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 05:46:57 +00:00
fullstack-engineer 508a5976e8 fix(handlers): log DB Scan errors previously silently ignored (3 files)
E2E API Smoke Test / E2E API Smoke Test (pull_request) Blocked by required conditions
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 18s
Harness Replays / detect-changes (pull_request) Successful in 16s
CI / Detect changes (pull_request) Successful in 45s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 18s
gate-check-v3 / gate-check (pull_request) Successful in 20s
qa-review / approved (pull_request) Successful in 21s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 55s
security-review / approved (pull_request) Successful in 22s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m2s
sop-tier-check / tier-check (pull_request) Successful in 22s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m26s
Harness Replays / Harness Replays (pull_request) Successful in 11s
CI / Canvas (Next.js) (pull_request) Successful in 19s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 17s
CI / Python Lint & Test (pull_request) Successful in 9s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 11s
CI / Platform (Go) (pull_request) Failing after 4m22s
E2E API Smoke Test / detect-changes (pull_request) Failing after 11m15s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 5m27s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 11s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
tokens.go Create: COUNT query Scan error ignored — if DB fails, count=0,
bypassing the per-workspace token rate limit. Now logs the error and
fails open (DB errors should not block token creation).

memories.go Commit: GLOBAL scope parent lookup Scan error ignored — if
DB fails, workspace is incorrectly treated as root, allowing a forbidden
GLOBAL write. Now returns 500 (fail closed, security-sensitive path).

memories.go Search: parent lookup Scan error ignored — DB failure causes
wrong TEAM-scope search results (self-only filter instead of team filter).
Now logs and falls back to self-only (functional degradation, not
security).

container_files.go List: workspace name lookup Scan error ignored — now
logs and continues (non-critical; container name candidates still tried).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 03:16:07 +00:00
3 changed files with 19 additions and 5 deletions
@@ -6,6 +6,7 @@ import (
"context"
"fmt"
"io"
"log"
"path/filepath"
"strings"
@@ -31,7 +32,9 @@ func (h *TemplatesHandler) findContainer(ctx context.Context, workspaceID string
}
// Also check by workspace name from DB
var wsName string
db.DB.QueryRowContext(ctx, `SELECT LOWER(REPLACE(name, ' ', '-')) FROM workspaces WHERE id = $1`, workspaceID).Scan(&wsName)
if err := db.DB.QueryRowContext(ctx, `SELECT LOWER(REPLACE(name, ' ', '-')) FROM workspaces WHERE id = $1`, workspaceID).Scan(&wsName); err != nil {
log.Printf("List: workspace name lookup for %s: %v", workspaceID, err)
}
if wsName != "" {
candidates = append(candidates, wsName)
}
+10 -2
View File
@@ -166,7 +166,11 @@ func (h *MemoriesHandler) Commit(c *gin.Context) {
// GLOBAL scope: only root workspaces (no parent) can write
if body.Scope == "GLOBAL" {
var parentID *string
db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID)
if err := db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID); err != nil {
log.Printf("Commit: parent lookup for workspace %s: %v", workspaceID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "workspace lookup failed"})
return
}
if parentID != nil {
c.JSON(http.StatusForbidden, gin.H{"error": "only root workspaces can write GLOBAL memories"})
return
@@ -278,7 +282,11 @@ func (h *MemoriesHandler) Search(c *gin.Context) {
// Get workspace info for access control
var parentID *string
db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID)
if err := db.DB.QueryRowContext(ctx, `SELECT parent_id FROM workspaces WHERE id = $1`, workspaceID).Scan(&parentID); err != nil {
// Non-critical: fall back to self-only team filter
log.Printf("Search: parent lookup for workspace %s: %v", workspaceID, err)
parentID = nil
}
// Try to generate a query embedding for semantic search.
// Falls back to the existing FTS/ILIKE path on failure or when no
+5 -2
View File
@@ -88,9 +88,12 @@ func (h *TokenHandler) Create(c *gin.Context) {
// Rate limit: max active tokens per workspace
var count int
db.DB.QueryRowContext(c.Request.Context(),
if err := db.DB.QueryRowContext(c.Request.Context(),
`SELECT COUNT(*) FROM workspace_auth_tokens WHERE workspace_id = $1 AND revoked_at IS NULL`,
workspaceID).Scan(&count)
workspaceID).Scan(&count); err != nil {
log.Printf("tokens: rate-limit count lookup for %s: %v", workspaceID, err)
count = 0 // fail open — a DB error should not block token creation
}
if count >= maxTokensPerWorkspace {
c.JSON(http.StatusTooManyRequests, gin.H{"error": fmt.Sprintf("maximum %d active tokens per workspace", maxTokensPerWorkspace)})
return