Skip to content

Bug: regenerate-iam fails due to audit_log column name mismatch #30

Closed

Description

@neuromechanist

Description

The nemar admin regenerate-iam command fails for all users with the error:

Failed to create IAM credentials

Root Cause

In backend/src/routes/admin.ts:571-579, the audit_log INSERT statement uses incorrect column names:

  • Uses: entity_type and entity_id
  • Should use: resource_type and resource_id

The actual error from the API:

{
  "error": "Failed to create IAM credentials",
  "details": "D1_ERROR: table audit_log has no column named entity_type: SQLITE_ERROR"
}

Affected Code

// Line 571-579 in backend/src/routes/admin.ts
await db
  .prepare("INSERT INTO audit_log (user_id, action, entity_type, entity_id, details) VALUES (?, ?, ?, ?, ?)")
  .bind(...)
  .run();

Compare with the correct usage in the approve endpoint (line 228-245):

await db
  .prepare(`INSERT INTO audit_log (user_id, action, resource_type, resource_id, details) VALUES (...)`)

Steps to Reproduce

  1. Run nemar admin regenerate-iam <username>
  2. Confirm the action
  3. Observe the failure

Additional Issue

The regenerate-iam command also does not grant admins access to the whole bucket. Admin users should have bucket-wide access, not just access to their own datasets.

Fix

  1. Change entity_type to resource_type and entity_id to resource_id in the audit_log INSERT
  2. For admin users, generate a policy with full bucket access instead of dataset-specific prefixes

Activity

  1. added a commit that references this issue on Jan 18, 2026
    a6d1f32
  2. added a commit that references this issue on Jan 18, 2026
    cf5052a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions