Skip to content

fix: domain-purchase data formatting + comprehensive CLI help#75

Merged
jpage-godaddy merged 2 commits into
rust-portfrom
various-formatting-things
Jun 30, 2026
Merged

fix: domain-purchase data formatting + comprehensive CLI help#75
jpage-godaddy merged 2 commits into
rust-portfrom
various-formatting-things

Conversation

@jpage-godaddy

Copy link
Copy Markdown
Collaborator

Addresses four data-formatting issues from the API Transformation MVP tracker bug bash (#12, #14, #27, #33).

#12 — phone normalization (contacts/mod.rs)

Contact::to_api() now normalizes phone (and fax) to the Domains API's required +<country-code>.<number> format using the new phonenumber crate, parsed with the contact's country as the default region. Inputs like +447793601890, +44 7793 601890, and a local 07793 601890 all become +44.7793601890; unparseable input fails fast with a plain-English error and an example.

#33 — omit blank optional fields (contacts/mod.rs)

Blank optional contact fields (address2, name_middle, organization, job_title, fax) are coerced to None so they're omitted rather than sent as "", which the API rejected with LENGTH_UNDER.

#14 — translate validation errors (domain/mod.rs)

format_api_error parses the API's fields[] array and renders a plain-English bullet list (friendly field name + problem + hint), e.g. "registrant mailing address line 2 is too short (leave it blank to omit it)". The raw regex-bearing messages are suppressed; the full JSON body stays available under --debug. Non-validation bodies (incl. the 402 path) keep their existing passthrough behavior.

#27 — comprehensive help pass

Root long help in main.rs, plus .with_long() and argument-help review across domain, dns, api, application, env, payments, webhook, and actions. Corrected an inaccurate "requires --reason" claim (the CLI registers no authorizer, so --reason is audit-only) and removed custom/local-environment language from user-facing help.

Testing

  • cargo test — 195 passing (14 new unit tests across contacts and domain)
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • Spot-checked rendered --help for root, domain purchase, dns, api call, application add subscription, and env commands

🤖 Generated with Claude Code

Address four bug-bash issues from the API Transformation MVP tracker:

- #12 Normalize contact phone/fax to the Domains API's `+<code>.<number>`
  format via the `phonenumber` crate (parsing with the contact's country as
  the default region), so common inputs like `+44 7793 601890` or a local
  `07793 601890` are accepted instead of returning a cryptic 422.
- #33 Omit blank optional contact fields (address2, name_middle,
  organization, job_title, fax) instead of sending empty strings, which the
  API rejects with LENGTH_UNDER.
- #14 Translate Domains API validation errors (`fields[]`) into plain-English
  guidance in `format_api_error`, suppressing the raw regex-bearing messages;
  the raw body remains available under `--debug`.
- #27 Comprehensive help pass: root long help, plus `.with_long()` and
  argument-help review across domain, dns, api, application, env, payments,
  webhook, and actions commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

This PR fixes Domains “purchase” request formatting issues and improves the CLI’s self-documentation by adding comprehensive long-form help across many command groups. It normalizes contact data to match Domains API expectations, renders validation errors as plain-English summaries, and expands --help guidance for major command surfaces.

Changes:

  • Normalize contacts.toml phone/fax values to the Domains API +<code>.<number> format and omit blank optional contact fields instead of sending "".
  • Translate Domains API structured validation errors (fields[]) into a friendly bullet list, while preserving access to the raw JSON body under --debug.
  • Add/refresh long help strings for root and multiple command groups to make CLI discovery easier.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rust/src/contacts/mod.rs Normalizes phone/fax, coerces blank optional fields to None, and adds unit tests.
rust/src/domain/mod.rs Adds friendly validation error rendering + tests; expands long help for domain commands.
rust/src/main.rs Adds root long help and updates global --env help text.
rust/src/env/mod.rs Adds long help for env group and subcommands.
rust/src/dns/mod.rs Adds long help for dns group and subcommands.
rust/src/api_explorer/mod.rs Adds long help for API explorer group and commands.
rust/src/application/commands/mod.rs Adds long help for application commands and “add” subgroups.
rust/src/actions_catalog/mod.rs Adds long help for actions catalog group and commands.
rust/src/payments/mod.rs Adds long help for payments group.
rust/src/webhook/mod.rs Adds long help for webhook group and events command.
rust/Cargo.toml Adds phonenumber dependency.
rust/Cargo.lock Locks new transitive dependencies from phonenumber.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/src/main.rs
Comment thread rust/src/env/mod.rs
Comment thread rust/src/env/mod.rs
Comment thread rust/src/domain/mod.rs Outdated
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

@jpage-godaddy jpage-godaddy merged commit 5d15d6d into rust-port Jun 30, 2026
2 checks passed
@jpage-godaddy jpage-godaddy deleted the various-formatting-things branch June 30, 2026 18:26
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