Skip to content

Prod - April release - Better logging and fix for crashing issue seen in dev - #262

Merged
jmgasper merged 1 commit into
masterfrom
develop
Apr 14, 2026
Merged

Prod - April release - Better logging and fix for crashing issue seen in dev#262
jmgasper merged 1 commit into
masterfrom
develop

Conversation

@jmgasper

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve observability and address a dev crash by enhancing HTTP error logging, adjusting Datadog HTTP client propagation behavior, and standardizing outbound Topcoder API base URLs.

Changes:

  • Added logger.logHttpError and expanded redaction to include Authorization fields.
  • Switched several outbound axios calls from API_BASE_URL to the new TOPCODER_API_URL, and added detailed logging for getSkill failures.
  • Added Datadog HTTP client propagation blocking for the standardized-skills endpoint, and introduced mise.toml to pin Node.js tooling.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/common/logger.js Adds structured HTTP client error logging and expands sensitive-field redaction.
src/common/helper.js Routes outbound Topcoder API calls through TOPCODER_API_URL and logs standardized-skills API failures.
config/default.js Introduces TOPCODER_API_URL configuration for outbound platform API calls.
app.js Configures dd-trace HTTP client propagation blocking for a standardized-skills endpoint.
mise.toml Pins Node.js tool version for local/dev tooling consistency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app.js
Comment on lines +9 to +10
// The standardized-skills API rejects Datadog propagation headers on this endpoint.
propagationBlocklist: [/api\.topcoder-dev\.com\/v5\/standardized-skills/]

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

propagationBlocklist is hard-coded to the dev domain (api.topcoder-dev.com). If this service is pointed at a different Topcoder API host (e.g., prod via TOPCODER_API_URL), Datadog propagation headers will still be injected and the crash/400s may persist. Consider matching on the standardized-skills path regardless of host (or deriving the host from configuration and supporting both dev/prod).

Suggested change
// The standardized-skills API rejects Datadog propagation headers on this endpoint.
propagationBlocklist: [/api\.topcoder-dev\.com\/v5\/standardized-skills/]
// The standardized-skills API rejects Datadog propagation headers on this endpoint,
// regardless of which Topcoder API host is configured.
propagationBlocklist: [/\/v5\/standardized-skills(?:\/|$|\?)/]

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jmgasper there is a point here. We need to capture for prod env too...

Comment thread config/default.js
// used to properly set the header response to api calls for services behind a load balancer
API_BASE_URL: process.env.API_BASE_URL || 'http://localhost:3000',
// used for outbound calls to Topcoder platform APIs
TOPCODER_API_URL: process.env.TOPCODER_API_URL || 'https://api.topcoder-dev.com',

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

TOPCODER_API_URL defaults to the dev API domain. Since config/ only contains default.js and test.js, a missing TOPCODER_API_URL env var in a prod deployment would silently route outbound calls to dev. Consider defaulting to the production domain and overriding for dev via env/config, or adding an environment-specific config (e.g., config/production.js/config/development.js) to make the intended target explicit.

Suggested change
TOPCODER_API_URL: process.env.TOPCODER_API_URL || 'https://api.topcoder-dev.com',
TOPCODER_API_URL: process.env.TOPCODER_API_URL || 'https://api.topcoder.com',

Copilot uses AI. Check for mistakes.
Comment thread src/common/logger.js
Comment on lines 74 to 78
return JSON.parse(JSON.stringify(obj, (name, value) => {
// Array of field names that should not be logged
// add field if necessary (password, tokens etc)
const removeFields = ['userToken']
const removeFields = ['userToken', 'authorization', 'Authorization']
if (_.includes(removeFields, name)) {

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

_sanitizeObject returns the original object unchanged when JSON serialization fails. Now that this is used for HTTP error logging, a serialization failure (e.g., circular refs/unserializable values in context or response payload) could cause sensitive fields (like Authorization tokens) to be logged unredacted. Consider making the failure path return a safely-redacted fallback (or performing redaction without relying on JSON.stringify).

Copilot uses AI. Check for mistakes.
Comment thread src/common/helper.js
Comment on lines +426 to +431
logger.logHttpError(err, {
operation: 'getSkill',
service: 'standardized-skills-api',
skillId,
skillUrl
})

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

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

getSkill now logs the axios error via logger.logHttpError and then rethrows. Since the Express error handler also calls logger.logFullError for all thrown errors, this request will be logged twice on every failure. Consider marking the error as already-logged (e.g., err.logged = true) or centralizing HTTP client error logging in the global error handler to avoid duplicate/error-level log spam.

Suggested change
logger.logHttpError(err, {
operation: 'getSkill',
service: 'standardized-skills-api',
skillId,
skillUrl
})
err.operation = 'getSkill'
err.service = 'standardized-skills-api'
err.skillId = skillId
err.skillUrl = skillUrl

Copilot uses AI. Check for mistakes.
Comment thread config/default.js
// used to properly set the header response to api calls for services behind a load balancer
API_BASE_URL: process.env.API_BASE_URL || 'http://localhost:3000',
// used for outbound calls to Topcoder platform APIs
TOPCODER_API_URL: process.env.TOPCODER_API_URL || 'https://api.topcoder-dev.com',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@jmgasper reminder to set this one to ParameterStore in prod & update the ECS task def to pick it up...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@jmgasper
jmgasper merged commit 1e400ea into master Apr 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants