Skip to content

Currency conversion fails for GBP due to missing exchange rate #101

@osw282

Description

@osw282

Issue Description

The currencyservice is experiencing conversion errors that result in zero amounts when converting to/from GBP (British Pound Sterling). This causes the service to fall back to the original currency and triggers error logging.

Root Cause Analysis

After analyzing the pod logs, I found repeated error messages:

"Currency conversion resulted in zero amount, switching back to original currency"

Upon examining the source code in src/currencyservice/server.js and the exchange rate data in src/currencyservice/data/currency_conversion.json, I discovered that the GBP entry has an empty value:

"GBP": ""

When the conversion logic divides by this empty string, it results in zero amounts, triggering the error handling code that reverts to the original currency.

Impact

  • Currency conversions involving GBP fail
  • Error messages flood the logs
  • Users cannot successfully convert prices to/from British Pounds
  • Service reliability is compromised for UK users

Recommended Fix

Update the src/currencyservice/data/currency_conversion.json file to include a proper exchange rate for GBP. Based on the other rates in the file (which appear to be EUR-based), a reasonable value would be approximately:

"GBP": "0.8745"

This represents the historical EUR to GBP conversion rate that aligns with the other rates in the dataset.

Additional Considerations

  • Consider adding validation logic to prevent empty or invalid exchange rates
  • Implement proper error handling that doesn't silently fall back but instead returns meaningful error messages
  • Add monitoring alerts for conversion failures
  • Consider using a real-time currency API for more accurate and up-to-date exchange rates

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions