Skip to content

Error logging on: Contact registrant: Domain registry contact error#442

Open
mmeest wants to merge 5 commits intomasterfrom
registry-api-error-notification
Open

Error logging on: Contact registrant: Domain registry contact error#442
mmeest wants to merge 5 commits intomasterfrom
registry-api-error-notification

Conversation

@mmeest
Copy link
Contributor

@mmeest mmeest commented Sep 25, 2025

Regarding issue #439

Add structured JSON error logging for Contact registrant Registry API failures

This PR introduces structured, machine-readable error logging for the Contact registrant flow when communication with the Registry API fails. Logging is implemented in registry_connector.rb following EIS logging standards (NDJSON, timestamped, with consistent keys and sanitized details).

Three types of errors are now handled:

  • Registry API CommunicationError – non-success HTTP response from the Registry API (e.g., 4xx/5xx).
  • Registry API NetworkError – networking issues such as timeout, connection refused, DNS errors.
  • Registry API UnexpectedError – unexpected runtime exceptions (e.g., JSON parsing errors, other exceptions).

Example structured log outputs (JSON)

CommunicationError:

{
  "timestamp": "2025-09-25T12:34:56.789Z",
  "level": "error",
  "message": "Registry API communication error",
  "event": "registry.api.communication_error",
  "service": "rest-whois",
  "environment": "prod",
  "host": "server01.example.com",
  "pid": 12345,
  "error": {
    "type": "CommunicationError",
    "message": "HTTP 500"
  },
  "details": {
    "url": "https://registry.example/api/v1/contact_requests",
    "request_method": "POST",
    "request_uri": "/api/v1/contact_requests",
    "response_body": "{\"error\":\"Internal server error\"}"
  },
  "schema_version": "1.0.0",
  "log_version": "1.0.0"
}

NetworkError:

{
  "timestamp": "2025-09-25T12:35:01.123Z",
  "level": "error",
  "message": "Registry API network connection failed",
  "event": "registry.api.network_error",
  "service": "rest-whois",
  "environment": "prod",
  "host": "server01.example.com",
  "pid": 12345,
  "error": {
    "type": "Net::OpenTimeout",
    "message": "execution expired"
  },
  "details": {
    "url": "https://registry.example/api/v1/contact_requests",
    "request_method": "POST",
    "request_uri": "/api/v1/contact_requests"
  },
  "schema_version": "1.0.0",
  "log_version": "1.0.0"
}

UnexpectedError:

{
  "timestamp": "2025-09-25T12:35:10.456Z",
  "level": "error",
  "message": "Registry API unexpected error",
  "event": "registry.api.unexpected_error",
  "service": "rest-whois",
  "environment": "prod",
  "host": "server01.example.com",
  "pid": 12345,
  "error": {
    "type": "JSON::ParserError",
    "message": "765: unexpected token at ''",
    "stack": "app/services/registry_connector.rb:23 | app/controllers/contact_requests_controller.rb:45"
  },
  "details": {
    "url": "https://registry.example/api/v1/contact_requests",
    "request_method": "POST",
    "request_uri": "/api/v1/contact_requests"
  },
  "schema_version": "1.0.0",
  "log_version": "1.0.0"
}
  • Logs are structured JSON suitable for machine parsing and NDJSON ingestion.
  • Includes timestamp, log level, event, service, host, process id, error object, and request details.
  • Avoids logging PII; only necessary request and response info is included.
  • Differentiates between network, communication, and unexpected errors for better observability and debugging.

@mmeest mmeest requested review from maricavor and removed request for maricavor September 25, 2025 10:18
Copy link
Contributor

@maricavor maricavor left a comment

Choose a reason for hiding this comment

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

Could you refactor method perform_request, now it is too big and not DRY. Also maybe add tests for different error scenarios?

@mmeest
Copy link
Contributor Author

mmeest commented Jan 23, 2026

Refactored perform_request method and added tests

@mmeest mmeest requested a review from maricavor January 23, 2026 14:59
@OlegPhenomenon OlegPhenomenon force-pushed the registry-api-error-notification branch from e264e98 to 93567a1 Compare February 5, 2026 10:21
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

🚀 Deploy Complete!

Property Value
App restwhois
Slot 1
URL https://restwhois1-dev.cloud.tld.ee
Namespace restwhois1-dev

(Environment ready for testing)

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