Skip to content

Add comment write endpoint for Helper#4331

Merged
gianfrancopiana merged 12 commits intomainfrom
gianfranco/helper-create-comment-endpoint
Apr 10, 2026
Merged

Add comment write endpoint for Helper#4331
gianfrancopiana merged 12 commits intomainfrom
gianfranco/helper-create-comment-endpoint

Conversation

@gianfrancopiana
Copy link
Copy Markdown
Member

@gianfrancopiana gianfrancopiana commented Apr 6, 2026

Ref https://github.com/antiwork/gumroad-private/issues/280

Depends on #4317.

What

Adds POST /api/internal/helper/users/create_comment — lets Helper and Gumclaw create note-type comments on Gumroad users.

  • Endpoint with required email, content, and idempotency_key parameters
  • Uses GUMROAD_ADMIN_ID as author — bypasses adult-keyword validation, provides audit attribution
  • Idempotency: same key + same content returns existing comment; same key + different content returns 409 Conflict. Backed by a unique composite index on (commentable_type, commentable_id, idempotency_key). Handles concurrent retries via RecordNotUnique rescue.
  • OpenAPI schema registered in OpenapiController for Gumclaw discovery
  • Extracts HelperUserInfoService.serialize_comment as a shared class method (used by both the read and write paths)
  • Fixes migration version from 7.2 to 7.1 (matching the project's Rails version)

Why

Step 2 of the structured comments plan. Helper's internal notes were removed (antiwork/helper#1116) and Gumroad is now the single source of truth for comments. This endpoint gives Helper's sidebar and Gumclaw the ability to write comments back to Gumroad, completing the read-write loop started in #4317.


This PR was implemented with AI assistance using Claude Opus 4.6 and gpt‑5.4 xhigh

@gianfrancopiana gianfrancopiana self-assigned this Apr 6, 2026
Copy link
Copy Markdown
Contributor

@gumclaw gumclaw left a comment

Choose a reason for hiding this comment

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

Approved by Sahil.

gianfrancopiana and others added 3 commits April 8, 2026 15:43
… keys, add tests

- Extract Comment.normalize_content as a public class method, replacing
  fragile .send(:trim_extra_newlines) on throwaway Comment.new instances
- Standardize create_comment 400 error responses to use error_message key
  (matching 409/422 responses and other helper endpoints)
- Add test for normalization-equivalent idempotency (content differing
  only by extra newlines)
- Add test for RecordNotUnique race condition rescue path

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gianfrancopiana gianfrancopiana marked this pull request as ready for review April 8, 2026 19:50
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

👋 @gianfrancopiana — This PR has been open for 46h with no reviewers assigned. Consider requesting a review from a teammate to keep things moving.

This is an automated review-cycle reminder.

@slavingia slavingia removed the priority label Apr 9, 2026
@github-actions
Copy link
Copy Markdown

👋 @gianfrancopiana — This PR has been open for 71h with no reviewers assigned. Consider requesting a review from a teammate to keep things moving.

This is an automated review-cycle reminder.

@github-actions
Copy link
Copy Markdown

👋 @gianfrancopiana — This PR has been open for 77h with no reviewers assigned. Consider requesting a review from a teammate to keep things moving.

This is an automated review-cycle reminder.

@github-actions
Copy link
Copy Markdown

👋 @gianfrancopiana — This PR has been open for 82h with no reviewers assigned. Consider requesting a review from a teammate to keep things moving.

This is an automated review-cycle reminder.

render json: { success: false, error_message: comment.errors.full_messages.join(", ") }, status: :unprocessable_entity
end
rescue ActiveRecord::RecordNotUnique
existing = user.comments.find_by!(idempotency_key: params[:idempotency_key])
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

False positive.

@gianfrancopiana gianfrancopiana merged commit 4fbe9a0 into main Apr 10, 2026
97 checks passed
@gianfrancopiana gianfrancopiana deleted the gianfranco/helper-create-comment-endpoint branch April 10, 2026 20:58
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