Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- `nr domain` manages domain names: `search`, `check`, `list`, `get`, `order`, `register`, `transfer`, `renew`, `nameservers set`, `autorenew on|off`, `lock on|off`, `dnssec`, `auth-code` and `contacts list`. Purchases are card only, show the price with tax, need the terms version (`--accept-terms`) and, with auto-renew, consent to renewal charges (`--mit-consent`); `--yes` skips the prompts. A card that needs 3-D Secure gets a portal link instead. See [docs/DOMAINS.md](docs/DOMAINS.md).
- API errors keep the `google.rpc.ErrorInfo` reason and metadata.

## [1.0.21] - 2026-11-29

### Added
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ nr cluster operator upgrade
nr cluster deregister --name edge-ams-01
```

Domain names (search, register, transfer, renew, nameservers, DNSSEC, auto-renew) are under
`nr domain`; see [Domains](docs/DOMAINS.md).

Diagnostic messages go to **stderr**. Use `--output json` when you need machine-readable **stdout**. Exit codes: `0` success, `1` runtime failure, `2` usage error.

## Configuration
Expand All @@ -108,7 +105,6 @@ Optional config lives at `~/.nr/config.yaml`. Production API default is `https:/

- [Install](docs/INSTALL.md)
- [Configuration](docs/CONFIG.md)
- [Domains](docs/DOMAINS.md)
- [Troubleshooting](docs/TROUBLESHOOTING.md)
- [Security](SECURITY.md)
- [Contributing](CONTRIBUTING.md)
Expand Down
72 changes: 0 additions & 72 deletions docs/DOMAINS.md

This file was deleted.

49 changes: 0 additions & 49 deletions internal/api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ type APIError struct {
Message string
Details string
Code string // gRPC error code (e.g., "NOT_FOUND", "ALREADY_EXISTS")
// Reason and Metadata come from the first google.rpc.ErrorInfo detail
// (e.g. REQUIRES_PORTAL_VERIFICATION with metadata portal_url).
Reason string
Metadata map[string]string
}

// ErrorReason returns the google.rpc.ErrorInfo reason of an API error, or "".
func ErrorReason(err error) string {
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr != nil {
return apiErr.Reason
}
return ""
}

// ErrorMetadata returns one google.rpc.ErrorInfo metadata value of an API error, or "".
func ErrorMetadata(err error, key string) string {
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr != nil {
return apiErr.Metadata[key]
}
return ""
}

func (e *APIError) Error() string {
Expand Down Expand Up @@ -224,7 +202,6 @@ func fillAPIErrorFromObject(apiErr *APIError, obj map[string]json.RawMessage) {
if json.Unmarshal(raw, &details) != nil || len(details) == 0 {
return
}
applyErrorInfo(apiErr, details)
d := details[0]
if raw, ok := d["code"]; ok {
var s string
Expand All @@ -240,32 +217,6 @@ func fillAPIErrorFromObject(apiErr *APIError, obj map[string]json.RawMessage) {
}
}

// applyErrorInfo copies the reason and metadata of the first google.rpc.ErrorInfo detail.
func applyErrorInfo(apiErr *APIError, details []map[string]json.RawMessage) {
for _, d := range details {
var typ string
if raw, ok := d["@type"]; !ok || json.Unmarshal(raw, &typ) != nil || !strings.HasSuffix(typ, "google.rpc.ErrorInfo") {
continue
}
var info struct {
Reason string `json:"reason"`
Metadata map[string]string `json:"metadata"`
}
if raw, ok := d["reason"]; ok {
_ = json.Unmarshal(raw, &info.Reason)
}
if raw, ok := d["metadata"]; ok {
_ = json.Unmarshal(raw, &info.Metadata)
}
if info.Reason == "" {
continue
}
apiErr.Reason = info.Reason
apiErr.Metadata = info.Metadata
return
}
}

func applyStatusHeaders(apiErr *APIError, header http.Header) {
if header == nil {
return
Expand Down
20 changes: 0 additions & 20 deletions internal/api/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,3 @@ func TestIsProviderReviewPendingWrapped(t *testing.T) {
t.Fatal("generic 403 must not be treated as marketplace review")
}
}

func TestParseErrorErrorInfo(t *testing.T) {
t.Parallel()

body := `{"code":9,"message":"This card needs verification.","details":[` +
`{"@type":"type.googleapis.com/google.rpc.DebugInfo","detail":"x"},` +
`{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"REQUIRES_PORTAL_VERIFICATION","domain":"api","metadata":{"portal_url":"https://noderings.com/domains/checkout/o1"}}]}`
resp := &http.Response{StatusCode: http.StatusBadRequest, Status: "400 Bad Request", Body: io.NopCloser(strings.NewReader(body))}
err := fmt.Errorf("checkout: %w", ParseError(resp))

if got := ErrorReason(err); got != "REQUIRES_PORTAL_VERIFICATION" {
t.Fatalf("ErrorReason = %q", got)
}
if got := ErrorMetadata(err, "portal_url"); got != "https://noderings.com/domains/checkout/o1" {
t.Fatalf("ErrorMetadata = %q", got)
}
if ErrorReason(fmt.Errorf("plain")) != "" || ErrorMetadata(nil, "x") != "" {
t.Fatal("non-API errors have no reason")
}
}
Loading
Loading