Skip to content

Improve error distinction between API failures and missing data #93

@senomorf

Description

@senomorf

Error Handling Enhancement: Network Failure Logging

Issue Description

The notification system currently uses a silent fallback when VNIC data cannot be retrieved, making it difficult to distinguish between legitimate missing IP addresses and actual network/API failures.

Current Code (Line 268)

# Line 268: Silent fallback might mask network issues
vnic_data='{"publicIp":null,"privateIp":null}'

Problem

Network failures are indistinguishable from missing IPs, which can hide:

  • API connectivity issues that might need attention
  • Authentication problems with OCI API
  • Network timeouts that could indicate broader issues
  • Quota/permission problems affecting VNIC access

Current Behavior

When VNIC data retrieval fails, the system:

  1. Falls back to null IP values
  2. Continues with notification (good)
  3. But provides no logging about why the failure occurred (problematic)

Recommended Solution

Add debug logging to distinguish between scenarios:

# Enhanced error handling with detailed logging
if ! vnic_data=$(oci_cmd network vnic get --vnic-id "$vnic_id" 2>/dev/null); then
    if [[ $? -eq 4 ]]; then
        log_debug "VNIC $vnic_id not found (expected for some configurations)"
    elif [[ $? -eq 1 ]]; then
        log_warning "Authentication/permission issue accessing VNIC $vnic_id"
    else
        log_warning "Network/API failure retrieving VNIC data for $vnic_id (exit code: $?)"
    fi
    vnic_data='{"publicIp":null,"privateIp":null}'
else
    log_debug "Successfully retrieved VNIC data for $vnic_id"
fi

Expected Benefits

  • Better troubleshooting of notification issues
  • Visibility into API health and connectivity problems
  • Distinguishes expected vs unexpected failures
  • Maintains current graceful degradation behavior
  • Improves debugging for operational issues

Priority

Medium - Improves debugging and operational visibility.

Context

Identified in PR #89 code review by Claude Code automated review system.

Acceptance Criteria

  • Add detailed error logging for VNIC data retrieval failures
  • Distinguish between different types of failures (auth, network, missing)
  • Maintain existing graceful degradation behavior
  • Add debug logging for successful VNIC retrievals
  • Test error scenarios to validate logging accuracy
  • Ensure logs don't expose sensitive information

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions