Skip to content

Fix missing GBP exchange rate in currency_conversion.json #59

@scott-clare1

Description

@scott-clare1

Issue Description

The currencyservice is failing when users attempt to convert currencies to GBP. The error logs show:

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

Root Cause

After investigating the code and logs, I found that in src/currencyservice/data/currency_conversion.json, the GBP exchange rate value is empty:

"GBP": "",

This causes the currency conversion calculation to yield zero amounts when converting to GBP, which triggers the error handling logic in the convert function in server.js. The specific code that handles this error is:

// Check if the result is zero
if (result.units === 0 && result.nanos === 0) {
  logger.error(`Currency conversion resulted in zero amount, switching back to original currency`);
  notifySlack();
  
  // Switch back to the original currency
  result.currency_code = request.from.currency_code;
  result.units = request.from.units;
  result.nanos = request.from.nanos;
  
  callback(null, result);
  return;
}

Proposed Fix

Update the currency_conversion.json file to include the correct exchange rate value for GBP:

"GBP": "0.8508",

This value is based on typical EUR to GBP exchange rates and should be updated with the most recent value if needed.

Impact

With this fix, users will be able to properly convert currencies to GBP, eliminating the error messages in the logs and preventing the service from falling back to the original currency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions