Skip to content

Add user message wire contract - #32

Open
atavism wants to merge 1 commit into
mainfrom
atavism/usermessage
Open

Add user message wire contract#32
atavism wants to merge 1 commit into
mainfrom
atavism/usermessage

Conversation

@atavism

@atavism atavism commented Aug 19, 2026

Copy link
Copy Markdown

Copilot AI lite review requested due to automatic review settings August 19, 2026 21:10
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6048ef98-b224-41af-b9f7-be23b7bd9d0a


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new usermessage package that defines and validates a v1 JSON wire contract for fetching resolved in-app user messages, along with embedded fixtures and compatibility/validation tests.

Changes:

  • Introduces v1 request/response/message/action types with explicit wire-size limits.
  • Adds validation for request, response, resolved message content, and allowlisted actions (including HTTPS URL validation).
  • Adds versioned embedded JSON fixtures and tests covering round-trip JSON compatibility and validation rules.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
usermessage/types.go Defines the v1 wire-contract structs, enums, and size-limit constants.
usermessage/validation.go Implements validation for the v1 request/response/message/action contract.
usermessage/types_test.go Adds fixture round-trip tests and targeted validation/limits tests.
usermessage/testfixtures/fixtures.go Exposes embedded, versioned JSON fixtures via an embed.FS.
usermessage/testfixtures/v1/request.json Adds a v1 request fixture used for compatibility tests.
usermessage/testfixtures/v1/response_empty.json Adds a v1 “no message” response fixture.
usermessage/testfixtures/v1/response_message.json Adds a v1 response fixture containing a message with an HTTPS URL action.
usermessage/testfixtures/v1/response_no_action.json Adds a v1 response fixture containing a message without an action.
usermessage/testfixtures/v1/response_open_plans.json Adds a v1 response fixture containing a message with an open_plans action.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread usermessage/validation.go
Comment on lines +164 to +187
parts := strings.Split(value, "-")
if len(parts) == 1 && (strings.EqualFold(parts[0], "x") || strings.EqualFold(parts[0], "i")) {
return invalid(field, "must include a subtag after the private-use or grandfathered prefix")
}
for i, part := range parts {
if len(part) == 0 || len(part) > 8 {
return invalid(field, "must be a BCP 47 language tag")
}
for _, r := range part {
if r > unicode.MaxASCII || !unicode.IsLetter(r) && !unicode.IsDigit(r) {
return invalid(field, "must contain only BCP 47 subtags")
}
}
if i == 0 {
if len(part) < 2 && !strings.EqualFold(part, "x") && !strings.EqualFold(part, "i") {
return invalid(field, "must begin with a language subtag")
}
for _, r := range part {
if !unicode.IsLetter(r) {
return invalid(field, "must begin with a language subtag")
}
}
}
}
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.

2 participants