Skip to content

fix: set user_id in context for service account auth path to prevent panic on project creation#181

Open
nimish22 wants to merge 7 commits into
mainfrom
fix/project-creation-panic
Open

fix: set user_id in context for service account auth path to prevent panic on project creation#181
nimish22 wants to merge 7 commits into
mainfrom
fix/project-creation-panic

Conversation

@nimish22

@nimish22 nimish22 commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

This is fix for issue #180


Summary by cubic

Prevents a panic during project creation with service account auth by setting missing context values and making getters safe. Fixes #180.

  • Bug Fixes
    • Set user_id, user_role, and user_email in the service account path in RequireAuth; also set user_email for standard and OAuth auth to keep context keys consistent.
    • Update BaseHandler getters to use safe string assertions and read user_role; add regression tests to ensure they don't panic when context values are missing.

Written for commit e7ca68e. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@nimish22 nimish22 force-pushed the fix/project-creation-panic branch from 28016a6 to 648dd28 Compare April 29, 2026 01:33
cwrm56
cwrm56 previously approved these changes May 13, 2026
cwrm56
cwrm56 previously approved these changes May 19, 2026

@cwrm56 cwrm56 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude suggests adding "a specific test for the service account project creation path — there's no test that sets up a service account context (with is_service_account=true and user_id set) and calls the project creation handler to verify it doesn't panic."
But I have approved.

@nimish22

nimish22 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Claude suggests adding "a specific test for the service account project creation path — there's no test that sets up a service account context (with is_service_account=true and user_id set) and calls the project creation handler to verify it doesn't panic." But I have approved.

Added tests as suggested.

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.

Creating a project via API with service account token returns 500

2 participants