Describe the bug
The svf-utils library currently does not support parsing the APS_REGION environment variable. As a result, the default region is set to US. Users who need to configure the region to EMEA or other regions are unable to do so using the current implementation.
To Reproduce
Steps to reproduce the behavior:
Set the APS_REGION environment variable to EMEA.
Run the svf-utils library.
Get back 404 along with ModelDerivativeApiError: getManifest Request failed with status : 404 and error message: undefined Observe in the logs that the region is still set to US.
Which is expected because there is no way to set the region to EMEA. The resource does not exist on the US region and we always get 404 back.
info: 03-06-2024 12:29:08: Initializing resiliency config: ResiliencyConfiguration (TimeOutValue: 15000) RetryCount: 5) (BackoffInterval: 10) (CircuitBreakerInterval: 60000)
info: 03-06-2024 12:29:08: Entered into fetchToken
info: 03-06-2024 12:29:08: fetchToken Request completed successfully with status code: 200
info: 03-06-2024 12:29:08: Entered into getManifest
error: 03-06-2024 12:29:09: getManifest Request failed with status : 404 and statusText : Not Found and error message: undefined
ModelDerivativeApiError: getManifest Request failed with status : 404 and error message: undefined
at ManifestApi.<anonymous> (...svf-utils/node_modules/@aps_sdk/model-derivative/dist/api/manifest-api.js:204:27)
at Generator.throw (<anonymous>)
at rejected (...svf-utils/node_modules/@aps_sdk/model-derivative/dist/api/manifest-api.js:8:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
axiosError: AxiosError: Request failed with status code 404
at settle (...svf-utils/node_modules/axios/dist/node/axios.cjs:1983:12)
at IncomingMessage.handleStreamEnd (...svf-utils/node_modules/axios/dist/node/axios.cjs:3085:11)
at IncomingMessage.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (...svf-utils/node_modules/axios/dist/node/axios.cjs:4224:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecuteWrapper.invoke (...svf-utils/node_modules/cockatiel/dist/common/Executor.js:40:27)
at async TimeoutPolicy.execute (...svf-utils/node_modules/cockatiel/dist/TimeoutPolicy.js:69:20)
at async ExecuteWrapper.invoke (...svf-utils/node_modules/cockatiel/dist/common/Executor.js:40:27)
at async RetryPolicy.execute (...svf-utils/node_modules/cockatiel/dist/RetryPolicy.js:55:28)
at async ExecuteWrapper.invoke (...svf-utils/node_modules/cockatiel/dist/common/Executor.js:40:27)
at async CircuitBreakerPolicy.execute (...svf-utils/node_modules/cockatiel/dist/CircuitBreakerPolicy.js:115:32) {
code: 'ERR_BAD_REQUEST'
While using something like postman and passing region=EMEA we can retrieve our resource successfully.
Expected behavior
The svf-utils library should correctly parse the APS_REGION environment variable and configure the region accordingly. For example, if APS_REGION is set to EMEA, the library should use the EMEA region instead of the default US region.
Environment :
svf-utils version: 5.0.3
Node.js version: 20.12.2
OS: M1, Sonoma 14.1
Proposed Solution
Add a mechanism to parse the APS_REGION environment variable and configure the region accordingly. Ensure that this variable can override the default region settings in the library.
Which can be done by utilising region parameter in readers.ts::213 FromDerivativeService function.
Thank you for your attention and thank you for a great library!
I will try to fix it and open a PR.
Describe the bug The
svf-utils
library currently does not support parsing theAPS_REGION
environment variable. As a result, the default region is set toUS
. Users who need to configure the region toEMEA
or other regions are unable to do so using the current implementation.To Reproduce Steps to reproduce the behavior:
APS_REGION
environment variable toEMEA
.svf-utils
library.404
along withModelDerivativeApiError: getManifest Request failed with status : 404 and error message: undefined
Observe in the logs that the region is still set toUS
. Which is expected because there is no way to set the region toEMEA
. The resource does not exist on theUS
region and we always get 404 back.More detailed error messages:
While using something like postman and passing
region=EMEA
we can retrieve our resource successfully.Expected behavior The
svf-utils
library should correctly parse theAPS_REGION
environment variable and configure the region accordingly. For example, ifAPS_REGION
is set toEMEA
, the library should use the EMEA region instead of the default US region.Environment :
svf-utils
version: 5.0.3Proposed Solution Add a mechanism to parse the
APS_REGION
environment variable and configure the region accordingly. Ensure that this variable can override the default region settings in the library. Which can be done by utilisingregion
parameter inreaders.ts::213 FromDerivativeService
function.Thank you for your attention and thank you for a great library! I will try to fix it and open a PR.