Skip to content

feat: add ucp_validate.py CLI readiness validator#34

Draft
sbeashwar wants to merge 3 commits intoUniversal-Commerce-Protocol:mainfrom
sbeashwar:pr3-validator
Draft

feat: add ucp_validate.py CLI readiness validator#34
sbeashwar wants to merge 3 commits intoUniversal-Commerce-Protocol:mainfrom
sbeashwar:pr3-validator

Conversation

@sbeashwar
Copy link
Copy Markdown

Description

Adds a standalone CLI tool that validates whether a merchant's UCP endpoint is ready for integration. Point it at any merchant URL, get a structured pass/fail report.

Features

  • Fetches and validates /.well-known/ucp discovery profile
  • Dual schema version support (2026-01-11 and 2026-01-23)
  • Structural consistency checking (version vs service/capability format)
  • Only dev.ucp.shopping.checkout is required; other declared capabilities are validated if present
  • Payment handler structural validation (required fields, reverse-DNS naming)
  • URL reachability checking for all spec/schema references
  • Signing key JWK format validation
  • Optional checkout smoke test (--smoke)
  • JSON output mode (--json) for CI/CD integration
  • Colored terminal output with ANSI badges
  • Exit code 0 for READY, 1 for NOT_READY
  • Zero new dependencies (reuses httpx + ucp-sdk already in the project)

Usage

uv run ucp_validate.py https://merchant.example.com
uv run ucp_validate.py http://localhost:8182 --smoke --verbose
uv run ucp_validate.py https://merchant.example.com --json
uv run ucp_validate.py http://localhost:8182 --skip-urls

Tested against

  • Flower Shop sample server: READY (13 PASS, 0 FAIL)
  • Unreachable endpoint: NOT_READY (exit code 1)

Depends on

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@sbeashwar sbeashwar requested review from a team as code owners April 17, 2026 23:41
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 17, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

SDK v0.3.0 renamed and restructured all model modules:
- UcpDiscoveryProfile deleted; use BusinessSchema from ucp.schemas.ucp
- *_resp modules renamed to base names (fulfillment_resp -> checkout)
- *_req modules renamed to *_request with matching class names
- Payment models moved to top-level payment.py
- Fulfillment models restructured with new required fields
- Service discovery uses flat transport model with ReverseDomainName keys

Test fixes:
- All 13 test files updated for new import paths and class names
- FulfillmentMethodCreateRequest: pass line_item_ids=[] (optional on
  create per spec, but SDK marks required)
- Fulfillment response access converted from typed attributes to dict
  subscript (extra="allow" models)
- Payment instrument construction standardized via get_valid_payment_payload()
- Protocol test version assertions updated for 2026-01-23

Result: 57/59 pass (2 simulation_secret config mismatches, not SDK issues)
…oded list

Replace hardcoded expected handler IDs (google_pay, mock_payment_handler,
shop_pay) with structural validation that:
- Discovers handlers from the business profile dynamically
- Validates required fields (id, version) are present
- Validates handler group names follow reverse-DNS convention
- Works against any UCP merchant, not just the Flower Shop

This makes the protocol conformance tests server-agnostic.
Standalone merchant readiness validator for UCP endpoints.
Point it at any merchant URL, get a structured pass/fail report.

Features:
- Fetches and validates /.well-known/ucp discovery profile
- Dual schema version support (2026-01-11 + 2026-01-23)
- Structural consistency checking (version vs service/capability format)
- Only checkout is required; other declared capabilities validated
- Payment handler validation (structure, reverse-DNS naming)
- URL reachability checking for all spec/schema references
- Signing key JWK format validation
- Optional checkout smoke test (--smoke)
- JSON output mode (--json)
- Colored terminal output with ANSI badges
- Exit code 0 for READY, 1 for NOT_READY

Usage:
  uv run ucp_validate.py https://merchant.example.com
  uv run ucp_validate.py http://localhost:8182 --smoke
  uv run ucp_validate.py https://merchant.example.com --json
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