Skip to content

Task 5011#5030

Merged
lukaszgryglicki merged 2 commits into
devfrom
unicron-5011
May 6, 2026
Merged

Task 5011#5030
lukaszgryglicki merged 2 commits into
devfrom
unicron-5011

Conversation

@lukaszgryglicki
Copy link
Copy Markdown
Member

No description provided.

@lukaszgryglicki lukaszgryglicki self-assigned this May 5, 2026
Copilot AI review requested due to automatic review settings May 5, 2026 06:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 303f529e-be26-4e7a-b7f2-09f8cd19f799

📥 Commits

Reviewing files that changed from the base of the PR and between 18c4b9e and b01fae1.

📒 Files selected for processing (2)
  • cla-backend-go/v2/cla_manager/emails.go
  • cla-backend-go/v2/cla_manager/pull_request_url_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cla-backend-go/v2/cla_manager/emails.go

Walkthrough

A pull request URL field is added across the CLA manager notification flow: API schemas, handler call, service interface and implementation, email models and templates, URL sanitization, and tests.

Changes

Pull Request URL Support

Layer / File(s) Summary
API Contract & Data Shape
cla-backend-go/swagger/cla.v2.yaml
Adds pullRequestURL (string) to POST /user/{userID}/invite-company-admin request body and to definitions.notify-cla-manager.
Template Params
cla-backend-go/emails/v2_cla_manager_templates.go
Adds PullRequestURL string to V2ContributorApprovalRequestTemplateParams and V2ContributorToOrgAdminTemplateParams; templates conditionally render a "Pull request" link when present.
URL Validation Logic
cla-backend-go/v2/cla_manager/emails.go
Introduces sanitizePullRequestURL(ctx, rawURL) string to trim and validate absolute https URLs with non-empty host, reject unsafe inputs, log warnings, and return "" on invalid input.
Email Models & Logging
cla-backend-go/v2/cla_manager/emails.go
Adds PullRequestURL to EmailToCLAManagerModel and pullRequestURL to ContributorEmailToOrgAdminModel; includes PR URL in structured logs and template params.
Service Interface & Implementation
cla-backend-go/v2/cla_manager/service.go
Updates InviteCompanyAdmin signature to accept pullRequestURL; sanitizes and propagates the PR URL into email models; NotifyCLAManagers now sanitizes and supplies PR URL to each manager email.
Handler Integration
cla-backend-go/v2/cla_manager/handlers.go
ClaManagerInviteCompanyAdminHandler passes params.Body.PullRequestURL into service.InviteCompanyAdmin.
Tests
cla-backend-go/tests/v2_cla_manager_templates_test.go, cla-backend-go/v2/cla_manager/pull_request_url_test.go
Template tests assert conditional rendering of the "Pull request" link; unit tests for sanitizePullRequestURL cover accepted HTTPS PR/MR/Change URLs, trimming, and many malformed/unsafe rejection cases.
Misc (Repo Ignore)
.gitignore
Adds CLAUDE.md to gitignore.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Handler as API Handler
    participant Service as CLA Manager Service
    participant Sanitizer as URL Sanitizer
    participant Model as Email Model
    participant Template as Email Template

    Client->>Handler: POST /invite-company-admin (pullRequestURL)
    Handler->>Service: InviteCompanyAdmin(..., pullRequestURL)
    Service->>Sanitizer: sanitizePullRequestURL(rawURL)
    Sanitizer-->>Service: sanitizedURL or ""
    Service->>Model: build EmailToCLAManagerModel / ContributorEmailToOrgAdminModel (PullRequestURL: sanitizedURL)
    Model->>Template: Render with params (PullRequestURL)
    Template-->>Model: Rendered HTML (conditional "Pull request" link)
    Model-->>Service: rendered email
    Service-->>Handler: operation result
    Handler-->>Client: response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Task 5011' is too vague and does not convey what changes are actually being made in the pull request. Update the title to describe the actual feature or change being implemented, e.g. 'Add pull request URL support to CLA manager emails'.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the intent aligns with the changes. Add a description explaining the purpose of these changes, the problem being solved, and how the pull request URL feature is used.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unicron-5011

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.1)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cla-backend-go/v2/cla_manager/emails.go`:
- Around line 31-35: The code is logging the full caller-controlled
pullRequestURL (in sanitizePullRequestURL and other spots), which can leak
secrets/PII; instead parse the rawURL and log only safe metadata: the hostname
(parsedURL.Host), a deterministic short hash (e.g., first 8 chars of
SHA256(rawURL)) and/or the URL with query stripped (scheme+host+path) but never
the full URL with query or tokens. Update the logrus.Fields in
sanitizePullRequestURL (replace "pullRequestURL": rawURL) to include
"pullRequestHost": parsed.Host and "pullRequestURLHash": <short-hash-of-rawURL>
and optionally "pullRequestURLNoQuery": <url-without-query>; apply the same
replacement at the other occurrences noted (the blocks around lines 142-156 and
220-233) so no codepath emits the raw pullRequestURL.
- Around line 21-57: sanitizePullRequestURL currently allows any absolute https
URL; tighten it to only accept known forge hosts and PR/MR/change URL shapes:
after parsing (in sanitizePullRequestURL) normalize parsed.Host (use
parsed.Hostname(), toLower, strip ports) and check it against an explicit
allowlist of trusted domains (e.g., github.com, gitlab.com, gerrit-hosts
configured centrally), then validate the path against provider-specific patterns
(e.g., GitHub "/pull/", GitLab "/-/merge_requests/" or Gerrit change URL shapes)
and return "" (with the existing log.WithFields warnings) if the host or path
pattern does not match; implement the allowlist as a package-level constant or
configurable list and add a small helper like isTrustedForgeHost(host) and
matchesForgePRPath(parsed, provider) to keep sanitizePullRequestURL readable.

In `@cla-backend-go/v2/cla_manager/service.go`:
- Around line 879-887: The log currently includes the raw user-supplied
pullRequestURL in the logrus.Fields map inside InviteCompanyAdmin; sanitize (or
strip sensitive query params/token fragments from) pullRequestURL once at the
start of InviteCompanyAdmin into a new variable (e.g., sanitizedPullRequestURL)
and replace the direct pullRequestURL reference in the f := logrus.Fields{...}
initializer with the sanitized variable (or remove the URL key entirely) so only
the cleaned value is logged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 045b2888-c2bc-4534-a506-4a1ae047f6bb

📥 Commits

Reviewing files that changed from the base of the PR and between 0e4d988 and 18c4b9e.

📒 Files selected for processing (8)
  • .gitignore
  • cla-backend-go/emails/v2_cla_manager_templates.go
  • cla-backend-go/swagger/cla.v2.yaml
  • cla-backend-go/tests/v2_cla_manager_templates_test.go
  • cla-backend-go/v2/cla_manager/emails.go
  • cla-backend-go/v2/cla_manager/handlers.go
  • cla-backend-go/v2/cla_manager/pull_request_url_test.go
  • cla-backend-go/v2/cla_manager/service.go

Comment thread cla-backend-go/v2/cla_manager/emails.go
Comment thread cla-backend-go/v2/cla_manager/emails.go
Comment thread cla-backend-go/v2/cla_manager/service.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional pull request URL to CLA-manager notification flows so approval/invitation emails can include a direct link back to the originating contribution.

Changes:

  • Extends the InviteCompanyAdmin service/API surface to accept a pullRequestURL.
  • Adds URL sanitization before injecting the link into outgoing CLA Manager / Org Admin emails.
  • Updates V2 email templates + tests to conditionally render the “Pull request:” link.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cla-backend-go/v2/cla_manager/service.go Threads pullRequestURL through invite + notify flows and passes a sanitized value into outbound email models.
cla-backend-go/v2/cla_manager/handlers.go Passes the new pullRequestURL request field through to the service layer.
cla-backend-go/v2/cla_manager/emails.go Introduces sanitizePullRequestURL and adds PullRequestURL to email model/template params.
cla-backend-go/v2/cla_manager/pull_request_url_test.go Adds unit tests covering accepted/rejected URL cases for sanitization.
cla-backend-go/emails/v2_cla_manager_templates.go Updates V2 CLA manager templates to conditionally include a pull request hyperlink.
cla-backend-go/tests/v2_cla_manager_templates_test.go Verifies templates omit the PR section when empty and render it when provided.
cla-backend-go/swagger/cla.v2.yaml Adds pullRequestURL to the invite-company-admin request body and notify-cla-manager-list schema.
.gitignore Ignores CLAUDE.md.

Comment thread cla-backend-go/v2/cla_manager/service.go
Comment thread cla-backend-go/v2/cla_manager/emails.go
Comment thread cla-backend-go/v2/cla_manager/emails.go
Comment thread cla-backend-go/swagger/cla.v2.yaml
Comment thread cla-backend-go/swagger/cla.v2.yaml
@lukaszgryglicki lukaszgryglicki merged commit 430ed5e into dev May 6, 2026
9 checks passed
@lukaszgryglicki lukaszgryglicki deleted the unicron-5011 branch May 6, 2026 03:36
lukaszgryglicki added a commit that referenced this pull request May 7, 2026
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.

3 participants