Skip to content

Use JSON.stringify for object interpolation in log statements to avoi…#311

Open
rhopp wants to merge 2 commits intoredhat-appstudio:mainfrom
rhopp:stringifyObjects
Open

Use JSON.stringify for object interpolation in log statements to avoi…#311
rhopp wants to merge 2 commits intoredhat-appstudio:mainfrom
rhopp:stringifyObjects

Conversation

@rhopp
Copy link
Copy Markdown
Collaborator

@rhopp rhopp commented Feb 27, 2026

…d [object Object]

Example of log before this change:

2026-02-26 22:58:24.053 [INFO ] rhdh.developer-hub: Creating component with options: [object Object] {projectName=e2e-go[github-tekton-quay-local], worker=0}

Summary by CodeRabbit

  • Bug Fixes

    • More robust handling of external API errors: sanitized error data is logged, logging is non-failing, and consistent error wrapping/propagation prevents logging from breaking flows.
  • Chores

    • Improved, structured diagnostic logging for resource creation and API interactions to produce clearer, safer messages.

@rhopp rhopp requested a review from xinredhat as a code owner February 27, 2026 07:30
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Use JSON.stringify for object interpolation in log statements

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace direct object interpolation with JSON.stringify in log statements
• Prevents [object Object] output in logs for better debugging
• Improves log readability for Azure API errors and responses
• Applies consistent object serialization across three service files
Diagram
flowchart LR
  A["Log statements with objects"] -- "Apply JSON.stringify" --> B["Serialized JSON in logs"]
  B -- "Result" --> C["Readable object output instead of [object Object]"]
Loading

Grey Divider

File Changes

1. src/api/azure/http/azure-http.client.ts ✨ Enhancement +2/-2

Stringify Azure HTTP error response objects

• Wrapped error.response.data with JSON.stringify() in error logging
• Wrapped error.request with JSON.stringify() in error logging
• Improves visibility of Azure DevOps API error details

src/api/azure/http/azure-http.client.ts


2. src/api/azure/services/azure-variable-group.service.ts ✨ Enhancement +1/-1

Stringify Azure variable group response object

• Wrapped response object with JSON.stringify() in info log
• Provides readable output for variable group creation responses

src/api/azure/services/azure-variable-group.service.ts


3. src/api/rhdh/developerhub.ts ✨ Enhancement +1/-1

Stringify component scaffold options object

• Wrapped componentScaffoldOptions with JSON.stringify() in info log
• Enables clear visibility of component scaffold configuration

src/api/rhdh/developerhub.ts


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Feb 27, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. JSON.stringify(error.request) logged📘 Rule violation ⛨ Security
Description
The new error logging stringifies and logs the full Axios error.request / error.response.data,
which can include sensitive data (e.g., auth headers, tokens, request payloads). This violates
secure logging requirements and can leak secrets into application logs.
Code

src/api/azure/http/azure-http.client.ts[R48-50]

+          this.logger.error(`Azure DevOps API Error: ${error.response.status} ${error.response.statusText} - ${JSON.stringify(error.response.data)}`);
       } else if (error.request) {
-          this.logger.error(`Azure DevOps API Error: No response received - ${error.request}`);
+          this.logger.error(`Azure DevOps API Error: No response received - ${JSON.stringify(error.request)}`);
Evidence
The compliance checklist forbids sensitive data in logs; logging entire request/response objects
(stringified) can capture credentials and PII/secret fields. The changed lines explicitly log
JSON.stringify(error.response.data) and JSON.stringify(error.request).

Rule 5: Generic: Secure Logging Practices
Rule 6: Generic: Security-First Input Validation and Data Handling
src/api/azure/http/azure-http.client.ts[48-50]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Current error logs stringify and emit full Axios request/response objects, which may contain secrets (Authorization headers), tokens, or sensitive payloads.
## Issue Context
Compliance requires that no sensitive data is present in logs; request/response objects are high-risk to log verbatim.
## Fix Focus Areas
- src/api/azure/http/azure-http.client.ts[48-50]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. response object logged fully📘 Rule violation ⛨ Security
Description
The new info log stringifies and logs the full variable group creation response, which may include
secret variables or other sensitive data. This can expose secrets in logs and violates secure
logging requirements.
Code

src/api/azure/services/azure-variable-group.service.ts[42]

+      this.logger.info(`AzureCI group creation response: ${JSON.stringify(response)}`);
Evidence
The compliance checklist forbids logging sensitive data; a full API response from variable group
creation can contain confidential values. The new code logs JSON.stringify(response) directly.

Rule 5: Generic: Secure Logging Practices
Rule 6: Generic: Security-First Input Validation and Data Handling
src/api/azure/services/azure-variable-group.service.ts[42-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code logs the full variable group creation response, which may contain sensitive information (e.g., secret variables).
## Issue Context
Secure logging rules require that secrets/PII are not written to logs; API responses should be filtered/redacted.
## Fix Focus Areas
- src/api/azure/services/azure-variable-group.service.ts[42-42]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. componentScaffoldOptions logged fully📘 Rule violation ⛨ Security
Description
The new log statement stringifies and logs componentScaffoldOptions, which may include
user-provided inputs and potentially sensitive configuration values. This increases the risk of
leaking secrets/PII into logs and violates secure logging requirements.
Code

src/api/rhdh/developerhub.ts[45]

+      this.logger.info(`Creating component with options: ${JSON.stringify(componentScaffoldOptions)}`);
Evidence
The compliance checklist requires that logs contain no sensitive data; scaffold options are an input
object that may carry confidential fields depending on usage. The changed line logs
JSON.stringify(componentScaffoldOptions) directly.

Rule 5: Generic: Secure Logging Practices
Rule 6: Generic: Security-First Input Validation and Data Handling
src/api/rhdh/developerhub.ts[45-45]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code logs the entire `componentScaffoldOptions` object, which can contain sensitive/user-provided data and should not be emitted verbatim.
## Issue Context
Secure logging and data-handling rules require preventing leakage of secrets/PII into logs; input objects should be sanitized/redacted before logging.
## Fix Focus Areas
- src/api/rhdh/developerhub.ts[45-45]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
4. Azure error logging may throw🐞 Bug ⛯ Reliability
Description
AzureHttpClient now JSON.stringify()'s Axios error objects inside the response error interceptor. If
serialization throws (e.g., due to non-JSON-safe structures), the interceptor will reject with that
thrown TypeError instead of the intended AzureApiError, masking the real HTTP failure and losing
status/data context.
Code

src/api/azure/http/azure-http.client.ts[R48-51]

+          this.logger.error(`Azure DevOps API Error: ${error.response.status} ${error.response.statusText} - ${JSON.stringify(error.response.data)}`);
       } else if (error.request) {
-          this.logger.error(`Azure DevOps API Error: No response received - ${error.request}`);
+          this.logger.error(`Azure DevOps API Error: No response received - ${JSON.stringify(error.request)}`);
       } else {
Evidence
The interceptor performs JSON.stringify() inline in the log message before constructing/returning
AzureApiError. Any exception during stringify will short-circuit the rest of the handler (including
the AzureApiError wrapping).

src/api/azure/http/azure-http.client.ts[44-62]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`AzureHttpClient` interpolates `JSON.stringify(error.response.data)` and `JSON.stringify(error.request)` directly into log messages inside the response error interceptor. If serialization throws, the interceptor will fail before wrapping the error into `AzureApiError`, and callers will see a different error (e.g., a stringify TypeError) instead of the real HTTP failure.
## Issue Context
This is in the error-handling path for Azure API calls, so it must be extremely robust. Axios error objects (especially `error.request`) are not guaranteed to be JSON-serializable.
## Fix Focus Areas
- src/api/azure/http/azure-http.client.ts[44-62]
## Suggested change
- Replace direct `JSON.stringify(...)` in template literals with a safe serializer:
- `safeStringify(value): string` that catches stringify errors and returns a fallback like `"[unserializable]"`.
- Add truncation (e.g., max N chars) to avoid huge logs.
- For `error.request`, log a curated subset instead of the full object (e.g., method, baseURL/url, timeout), and ensure Authorization/PAT are not logged.
- Keep error wrapping (`AzureApiError`) independent of logging, so wrapping always occurs even if logging fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Azure interceptor ignores ApiError🐞 Bug ✓ Correctness
Description
BaseHttpClient wraps AxiosError into ApiError in its response interceptor, but AzureHttpClient’s
interceptor still assumes AxiosError and reads error.response/error.request. When it receives an
ApiError, those fields are absent, so AzureApiError is created without status/data and the detailed
logging branches won’t execute, reducing debuggability and correctness of error propagation.
Code

src/api/azure/http/azure-http.client.ts[R46-53]

     (error: AxiosError) => {
       if (error.response) {
-          this.logger.error(`Azure DevOps API Error: ${error.response.status} ${error.response.statusText} - ${error.response.data}`);
+          this.logger.error(`Azure DevOps API Error: ${error.response.status} ${error.response.statusText} - ${JSON.stringify(error.response.data)}`);
       } else if (error.request) {
-          this.logger.error(`Azure DevOps API Error: No response received - ${error.request}`);
+          this.logger.error(`Azure DevOps API Error: No response received - ${JSON.stringify(error.request)}`);
       } else {
         this.logger.error(`Azure DevOps API Error: Request setup failed - ${error}`);
       }
Evidence
BaseHttpClient installs a response interceptor that converts AxiosError into ApiError and rejects
with that ApiError. AzureHttpClient installs another response interceptor but does not handle
ApiError (unlike JenkinsHttpClient which explicitly does), so it may not have access to
response/request on the error instance it receives.

src/api/common/http/base-http.client.ts[24-39]
src/api/azure/http/azure-http.client.ts[44-62]
src/api/jenkins/http/jenkins-http.client.ts[19-33]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`BaseHttpClient` wraps `AxiosError` into `ApiError`, but `AzureHttpClient`’s interceptor is written as if it always receives an `AxiosError` and reads `error.response` / `error.request`. If it receives an `ApiError`, these properties won’t exist, and Azure-specific wrapping/logging will lose the HTTP status/data.
## Issue Context
The repository already demonstrates the intended pattern in `JenkinsHttpClient`: handle `ApiError` first, then fall back to raw AxiosError.
## Fix Focus Areas
- src/api/azure/http/azure-http.client.ts[44-62]
- src/api/common/http/base-http.client.ts[24-39]
- src/api/jenkins/http/jenkins-http.client.ts[19-33]
## Suggested change
- Import `ApiError` in `azure-http.client.ts` and change the interceptor to:
- `if (error instanceof ApiError) {` log using `error.status`/`error.data` and `return Promise.reject(new AzureApiError(error.message, error.status, error.data, error)); }`
- `else if (axios.isAxiosError(error)) {` handle raw AxiosError as fallback
- `else {` generic
- Ensure logging uses the safe serialization approach (or logs only curated fields) so error wrapping is not impacted by logging failures.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@jkopriva has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 87aac304-2204-4aa1-bc2f-7e7316f14fce

📥 Commits

Reviewing files that changed from the base of the PR and between 6edd6d8 and c974b69.

📒 Files selected for processing (3)
  • src/api/azure/http/azure-http.client.ts
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts
📝 Walkthrough

Walkthrough

Azure HTTP client error handling was reworked: added a sanitizeErrorData helper and robust mapping of various error shapes into AzureApiError with sanitized logging. Logging was made structured in Azure variable group creation and RHDH createComponent. No public API signatures changed.

Changes

Cohort / File(s) Summary
Azure HTTP client
src/api/azure/http/azure-http.client.ts
Added sanitizeErrorData to truncate/format diverse error shapes; revamped error handling to map ApiError, HTTP response errors, no-response (request) and request-setup failures into AzureApiError; log sanitized data without throwing during logging; removed direct AxiosError typing import.
Azure variable group service
src/api/azure/services/azure-variable-group.service.ts
On create, destructure id and name from response and emit structured log Variable group created: id=<id>, name=<name> instead of logging raw response.
RHDH developer hub client
src/api/rhdh/developerhub.ts
createComponent logging changed to destructure componentScaffoldOptions and log templateRef, name, repoName, namespace, ciType, hostType in a structured message.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Caller
participant AzureHttpClient
participant HTTPLib as Axios/HTTP
participant Logger
Caller->>AzureHttpClient: invoke request
AzureHttpClient->>HTTPLib: send HTTP request
HTTPLib-->>AzureHttpClient: response or error
alt Successful response
AzureHttpClient-->>Caller: return response
else Error with response
AzureHttpClient->>Logger: log sanitizeErrorData(error.response)
AzureHttpClient-->>Caller: throw AzureApiError (with sanitized data)
else No response (timeout/network)
AzureHttpClient->>Logger: log request details (method, baseURL, url, timeout)
AzureHttpClient-->>Caller: throw AzureApiError (no-response variant)
else Request setup failure
AzureHttpClient->>Logger: log setup error message (sanitized)
AzureHttpClient-->>Caller: throw AzureApiError (setup-failure variant)
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to using JSON.stringify for object interpolation in log statements, which directly aligns with the changes made: structured logging with JSON.stringify in azure-http.client.ts, azure-variable-group.service.ts, and developerhub.ts to prevent '[object Object]' output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan for PR comments
  • Generate coding plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added enhancement New feature or request api-client labels Feb 27, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/api/azure/http/azure-http.client.ts`:
- Around line 48-52: The error handler logs error.request using JSON.stringify
which throws on circular structures; instead pull the request URL from the
AxiosError config and log that (e.g., use error.config?.url or combine
error.config?.baseURL + error.config?.url) so the this.logger.error call in the
Azure DevOps API Error "no response received" branch doesn't crash; update the
branch that currently references JSON.stringify(error.request) to log the
extracted URL (and optionally method) plus any safe scalar fields from
error.request rather than stringifying the whole object.

In `@src/api/azure/services/azure-variable-group.service.ts`:
- Line 42: The current info log in azure-variable-group.service.ts uses
JSON.stringify(response) which may expose secrets; update the logging to only
emit non-sensitive identifiers (e.g., response.id, response.name,
response.description) or call a sanitization helper (e.g.,
redactSensitiveFields(response) or sanitizeAzureResponse(response)) that
removes/redacts properties like variables, value, secret, content or any nested
credential fields before logging via this.logger.info; ensure the log uses the
sanitized object or explicit fields instead of the full response object.

In `@src/api/rhdh/developerhub.ts`:
- Line 45: The current this.logger.info call logs the full
componentScaffoldOptions (variable componentScaffoldOptions) which may contain
secrets; change it to avoid leaking sensitive data by either (a) lowering the
level to this.logger.debug when dumping the full options, or (b) replacing the
logged payload with a safe subset (e.g., { templateRef:
componentScaffoldOptions.templateRef, repoUrl:
componentScaffoldOptions.values?.repoUrl }) and keep the log at INFO; update the
call at the site where the component is created (the existing this.logger.info
line) to implement one of these approaches.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c65a7b0 and 4bb8504.

📒 Files selected for processing (3)
  • src/api/azure/http/azure-http.client.ts
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts

Comment thread src/api/azure/http/azure-http.client.ts Outdated
Comment thread src/api/azure/services/azure-variable-group.service.ts Outdated
Comment thread src/api/rhdh/developerhub.ts Outdated
Comment thread src/api/azure/http/azure-http.client.ts Outdated
Comment thread src/api/azure/services/azure-variable-group.service.ts Outdated
Comment thread src/api/rhdh/developerhub.ts Outdated
Comment thread src/api/azure/http/azure-http.client.ts Outdated
Comment thread src/api/azure/http/azure-http.client.ts Outdated
@coderabbitai coderabbitai bot added bug-fix and removed enhancement New feature or request api-client labels Feb 27, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/api/azure/http/azure-http.client.ts (1)

79-84: Minor: Dead code path in config extraction.

Line 82 attempts error.request?.config, but the Axios error.request property is a Node.js http.ClientRequest object which doesn't have a config property—this will always be undefined and fall through to error.config.

Not a bug (the fallback works correctly), but you can simplify to just use error.config:

🧹 Optional cleanup
         } else if (error.request) {
           azureError = new AzureApiError('No response received from Azure DevOps', undefined, undefined, error);
           try {
-            const { method, baseURL, url, timeout } = error.request?.config ?? error.config ?? {};
+            const { method, baseURL, url, timeout } = error.config ?? {};
             this.logger.error(`Azure DevOps API Error: No response received - ${method?.toUpperCase()} ${baseURL ?? ''}${url ?? ''} (timeout: ${timeout})`);
           } catch { /* logging must not break error propagation */ }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/api/azure/http/azure-http.client.ts` around lines 79 - 84, The axios
error handling contains a dead path using error.request?.config; simplify the
config extraction by removing the request branch and just destructure from
error.config (e.g. const { method, baseURL, url, timeout } = error.config ??
{}), then keep the existing logging inside the try/catch and preserve the
AzureApiError construction; update the code paths in the same error handling
block that reference error.request?.config so only error.config is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/api/azure/http/azure-http.client.ts`:
- Around line 79-84: The axios error handling contains a dead path using
error.request?.config; simplify the config extraction by removing the request
branch and just destructure from error.config (e.g. const { method, baseURL,
url, timeout } = error.config ?? {}), then keep the existing logging inside the
try/catch and preserve the AzureApiError construction; update the code paths in
the same error handling block that reference error.request?.config so only
error.config is used.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bb8504 and 17256fa.

📒 Files selected for processing (3)
  • src/api/azure/http/azure-http.client.ts
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/api/azure/services/azure-variable-group.service.ts

@rhopp
Copy link
Copy Markdown
Collaborator Author

rhopp commented Feb 27, 2026

/retest

2 similar comments
@rhopp
Copy link
Copy Markdown
Collaborator Author

rhopp commented Mar 3, 2026

/retest

@rhopp
Copy link
Copy Markdown
Collaborator Author

rhopp commented Mar 4, 2026

/retest

@rhopp rhopp force-pushed the stringifyObjects branch from 17256fa to b06993c Compare March 4, 2026 08:26
@coderabbitai coderabbitai bot added api-client and removed bug-fix labels Mar 4, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/api/azure/http/azure-http.client.ts`:
- Around line 86-89: The logging currently interpolates the raw error
(this.logger.error(`Azure DevOps API Error: Request setup failed - ${error}`))
which can produce “[object Object]”; update the catch branch in
azure-http.client.ts to serialize the error safely before logging: if the value
is an Error log error.stack (or error.message if stack missing); otherwise
attempt JSON.stringify(error) with a try/catch fallback to util.inspect(error)
or String(error); keep creating azureError (AzureApiError) as before but pass
the serialized message to this.logger.error to ensure useful output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fcc2dd04-3bbb-4e86-b249-fd83421cd5e7

📥 Commits

Reviewing files that changed from the base of the PR and between 17256fa and b06993c.

📒 Files selected for processing (3)
  • src/api/azure/http/azure-http.client.ts
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/api/azure/services/azure-variable-group.service.ts

Comment on lines +86 to +89
azureError = new AzureApiError('Request setup failed', undefined, undefined, error);
try {
this.logger.error(`Azure DevOps API Error: Request setup failed - ${error}`);
} catch { /* logging must not break error propagation */ }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid raw object interpolation in setup-failure logging.

This branch can still emit [object Object] for non-Error values, which weakens debugging output.

Suggested fix
         } else {
           azureError = new AzureApiError('Request setup failed', undefined, undefined, error);
           try {
-            this.logger.error(`Azure DevOps API Error: Request setup failed - ${error}`);
+            const detail = error instanceof Error ? error.message : sanitizeErrorData(error);
+            this.logger.error(`Azure DevOps API Error: Request setup failed - ${detail}`);
           } catch { /* logging must not break error propagation */ }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/api/azure/http/azure-http.client.ts` around lines 86 - 89, The logging
currently interpolates the raw error (this.logger.error(`Azure DevOps API Error:
Request setup failed - ${error}`)) which can produce “[object Object]”; update
the catch branch in azure-http.client.ts to serialize the error safely before
logging: if the value is an Error log error.stack (or error.message if stack
missing); otherwise attempt JSON.stringify(error) with a try/catch fallback to
util.inspect(error) or String(error); keep creating azureError (AzureApiError)
as before but pass the serialized message to this.logger.error to ensure useful
output.

@rhopp rhopp force-pushed the stringifyObjects branch from b06993c to 6edd6d8 Compare March 4, 2026 16:10
@coderabbitai coderabbitai bot added enhancement New feature or request and removed api-client labels Mar 4, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/api/azure/http/azure-http.client.ts`:
- Around line 82-83: The conditional uses a dead branch error.request?.config
(error.request is an http.ClientRequest and has no config); update the
extraction to pull method, baseURL, url, timeout only from error.config (e.g.,
replace the destructuring that uses error.request?.config ?? error.config ?? {}
with just error.config ?? {}), and keep the existing this.logger.error call
(Azure DevOps API Error...) unchanged so it logs method/baseURL/url/timeout from
the valid AxiosError config; target the destructuring near the this.logger.error
call in azure-http.client.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fcd1883d-77e3-4396-af96-6a41c2f2d593

📥 Commits

Reviewing files that changed from the base of the PR and between b06993c and 6edd6d8.

📒 Files selected for processing (3)
  • src/api/azure/http/azure-http.client.ts
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/api/azure/services/azure-variable-group.service.ts
  • src/api/rhdh/developerhub.ts

Comment on lines +82 to +83
const { method, baseURL, url, timeout } = error.request?.config ?? error.config ?? {};
this.logger.error(`Azure DevOps API Error: No response received - ${method?.toUpperCase()} ${baseURL ?? ''}${url ?? ''} (timeout: ${timeout})`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n src/api/azure/http/azure-http.client.ts | sed -n '75,95p'

Repository: redhat-appstudio/tssc-test

Length of output: 1415


🏁 Script executed:

rg -n "error\.request" src/api/azure/http/azure-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 210


🏁 Script executed:

rg -n "error\.request\?*\.config|error\.request\.config" --type ts src/

Repository: redhat-appstudio/tssc-test

Length of output: 211


🏁 Script executed:

rg -n "import.*axios|import.*AxiosError" src/api/azure/http/azure-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 52


🏁 Script executed:

rg -n "AxiosError|error:" src/api/azure/http/azure-http.client.ts -B 2 -A 2

Repository: redhat-appstudio/tssc-test

Length of output: 626


🏁 Script executed:

# Check if error is explicitly typed and how it's imported
rg -n "catch\s*\(\s*error" src/api/azure/http/azure-http.client.ts -A 1

Repository: redhat-appstudio/tssc-test

Length of output: 52


🏁 Script executed:

# Look for axios client setup to understand error handling context
head -50 src/api/azure/http/azure-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 1754


🏁 Script executed:

# Check for AxiosError type definitions or error type annotations
rg -n "catch.*error.*AxiosError|error\s*:\s*AxiosError|as AxiosError" src/api/azure/http/azure-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 52


🏁 Script executed:

# Check BaseHttpClient to understand what error types propagate
head -100 src/api/common/http/base-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 3206


🏁 Script executed:

# Search for axios usage in BaseHttpClient
rg -n "error\.request\|\.request\?\." src/api/common/http/base-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 52


🏁 Script executed:

# Check ApiError class to understand error.cause
rg -n "class ApiError|error\.cause" src/api/common/errors/api.errors.ts -A 5

Repository: redhat-appstudio/tssc-test

Length of output: 435


🏁 Script executed:

# Look at the full error handling block to understand context
sed -n '60,95p' src/api/azure/http/azure-http.client.ts

Repository: redhat-appstudio/tssc-test

Length of output: 2065


🏁 Script executed:

# Check the full ApiError class structure
cat -n src/api/common/errors/api.errors.ts

Repository: redhat-appstudio/tssc-test

Length of output: 3862


🏁 Script executed:

# Verify that in the else if (error.request) block, error is indeed AxiosError
# by checking what properties are being accessed
rg -n "error\.request|error\.config|error\.response" src/api/azure/http/azure-http.client.ts | head -20

Repository: redhat-appstudio/tssc-test

Length of output: 520


Remove dead code path—error.request doesn't have a config property.

In AxiosError, error.request is the Node.js http.ClientRequest object, which has no config property. The expression error.request?.config will always evaluate to undefined, making it unnecessary dead code. Simplify to access only error.config:

Suggested fix
-          const { method, baseURL, url, timeout } = error.request?.config ?? error.config ?? {};
+          const { method, baseURL, url, timeout } = error.config ?? {};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/api/azure/http/azure-http.client.ts` around lines 82 - 83, The
conditional uses a dead branch error.request?.config (error.request is an
http.ClientRequest and has no config); update the extraction to pull method,
baseURL, url, timeout only from error.config (e.g., replace the destructuring
that uses error.request?.config ?? error.config ?? {} with just error.config ??
{}), and keep the existing this.logger.error call (Azure DevOps API Error...)
unchanged so it logs method/baseURL/url/timeout from the valid AxiosError
config; target the destructuring near the this.logger.error call in
azure-http.client.ts.

rhopp and others added 2 commits March 12, 2026 15:41
…d [object Object]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ing in Azure HTTP client

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@konflux-ci-qe-bot
Copy link
Copy Markdown

@rhopp: The following test has Failed, say /retest to rerun failed tests.

PipelineRun Name Status Rerun command Build Log Test Log
e2e-4.20-tdhg5 Failed /retest View Pipeline Log View Test Logs

Inspecting Test Artifacts

To inspect your test artifacts, follow these steps:

  1. Install ORAS (see the ORAS installation guide).
  2. Download artifacts with the following commands:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/konflux-test-storage/rhtap-team/rhtap-cli:e2e-4.20-tdhg5

Test results analysis

<not enabled>

OCI Artifact Browser URL

<not enabled>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants