Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(identity-oci-auth): improve OCI error logging to handle header casing for opc-request-id

Victor Hugo dos Santos2d657e4edf23
diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-fns.test.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-fns.test.ts
index 82ded91d09..e8f1f49c0a 100644
--- a/backend/src/services/identity-oci-auth/identity-oci-auth-fns.test.ts
+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-fns.test.ts
@@ -27,6 +27,11 @@ describe("getOciErrorForLog", () => {
});
});
+ it("reads opc-request-id regardless of header-name casing", () => {
+ const err = ociError(401, { code: "NotAuthenticated" }, { "Opc-Request-Id": "D1B2C3/E4F5A6/B7C8D9" });
+ expect(getOciErrorForLog(err).ociRequestId).toBe("D1B2C3/E4F5A6/B7C8D9");
+ });
+
it("never returns the OCI message, which can echo client-supplied values", () => {
const echoed = "ocid1.user.oc1..aaaaaaaasecretvalue";
const logged = JSON.stringify(
diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-fns.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-fns.ts
index 33d2b15a13..e10c18c32b 100644
--- a/backend/src/services/identity-oci-auth/identity-oci-auth-fns.ts
+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-fns.ts
@@ -1,4 +1,4 @@
-import { AxiosError } from "axios";
+import { AxiosError, AxiosHeaders, RawAxiosHeaders } from "axios";
import RE2 from "re2";
const SIGNATURE_SCHEME = "signature ";
@@ -14,7 +14,9 @@ export const getOciErrorForLog = (err: AxiosError) => {
status: err.response?.status,
code: err.code,
ociErrorCode: toLoggableIdentifier(data?.code),
- ociRequestId: toLoggableIdentifier(err.response?.headers?.["opc-request-id"])
+ ociRequestId: err.response
+ ? toLoggableIdentifier(AxiosHeaders.from(err.response.headers as RawAxiosHeaders).get("opc-request-id"))
+ : undefined
};
};