Skip to content

Dev#22

Merged
ngovinh2k2 merged 4 commits into
mainfrom
dev
May 22, 2026
Merged

Dev#22
ngovinh2k2 merged 4 commits into
mainfrom
dev

Conversation

@ngovinh2k2
Copy link
Copy Markdown
Member

What?

Why?

How?

Testing?

  • Functional Testing
  • Security
  • Performance
  • Error Handling
  • Code Quality
  • Documentation
  • Database
  • Deployment
  • Final Review

Anything Else?

@ngovinh2k2 ngovinh2k2 merged commit 3eec131 into main May 22, 2026
1 check passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a template field to the Organization model and updates the initialization logic to handle organization templates. Key feedback includes a critical bug where the --org-template argument is missing from the management command's parser, which will cause the service to fail on startup. Other issues identified include the failure to persist the template value to the database during organization creation and a potential KeyError when accessing user emails in the authentication service.

return {
"org_name": kwargs.get("org_name") or os.getenv("ORG_NAME"),
"org_slug": kwargs.get("org_slug") or os.getenv("ORG_SLUG"),
"org_template": kwargs.get("org_template") or os.getenv("ORG_TEMPLATE"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The --org-template argument is missing from the add_arguments method in this command. Since docker-entrypoint.sh passes this flag, the command will fail with an 'unrecognized arguments' error, preventing the service from starting.

# Publish organization event
self._publish_org_event(org_id, org_slug, org_name, result)
self._send_celery_task(org_id, org_name, org_slug, user)
self._send_celery_task(org_id, org_name, org_slug, org_template, user)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The org_template value is passed to the Celery task but is not used to populate the template field of the Organization model during creation. The _create_organization_with_roles method should be updated to accept this parameter and include it in the Organization.objects.create call.

Comment on lines +36 to +38
template = models.CharField(
max_length=256, choices=OrganizationTemplate.choices, blank=True, null=True
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The template field is added here, but it is not being populated in the init_organization management command. This field will remain null in the database for newly initialized organizations.

Comment on lines +66 to +68
given_name = user_info_dict.get("given_name", "")
family_name = user_info_dict.get("family_name", "")
email = user_info_dict["email"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Accessing email directly from user_info_dict may raise a KeyError if the key is missing from the provider's response. It is safer to use .get() and handle the missing value explicitly, for example by raising a ValidationError.

    given_name = user_info_dict.get("given_name", "")
    family_name = user_info_dict.get("family_name", "")
    email = user_info_dict.get("email")
    if not email:
        raise ValidationError({"email": f"Email not provided by {provider}."})

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