Skip to content

Conversation

daniyelnnr
Copy link
Contributor

What is the purpose of this pull request?

This PR aims to fix CI pipeline issues where lint and test jobs were failing. The changes include:

  • Jest and TypeScript configuration updates: Upgraded Jest to v29.7.0 and ts-jest to v29.4.1, with proper ESM configuration
  • TSLint configuration fixes: Disabled object literal key sorting rules that were causing lint failures
  • Test improvements: Enhanced error handling in axios tracing tests with better Node.js version compatibility
  • Build process optimization: Updated build script to include linting before compilation
  • Code quality fixes: Resolved various linting errors across multiple source files
  • Mock file cleanup: Removed deprecated constants from diagnostics-semconv mock

What problem is this solving?

The CI pipeline was experiencing consistent failures in both lint and test jobs, preventing successful builds and deployments. The main issues were:

  1. Outdated testing framework: Jest and ts-jest versions were incompatible with current Node.js versions and ESM requirements
  2. Linting rule conflicts: TSLint's object literal sorting rules were causing unnecessary failures
  3. Test compatibility issues: Axios tracing tests had error handling that wasn't compatible across different Node.js versions
  4. Build process gaps: The build script wasn't properly validating code quality before compilation
  5. Deprecated dependencies: Mock files contained references to removed constants

How should this be manually tested?

Screenshots or example usage

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

Tests constants and their properties, checking attributes and headers introduced by the @vtex/diagnostics-semconv package
Refactor logger module to remove usage of deprecated attribute
Remove references to deprecated `VTEX_OPERATION_ID` in constants tests
Remove deprecated constant `ATTR_VTEX_OPERATION_ID` from diagnostics-semconv mock
This change disable sorting of object literal keys for both TypeScript and JavaScript files
- Modified the build script to include linting before cleaning and compiling
Upgrade `jest` to version 29.7.0 and `ts-jest` to version 29.4.1
- Modified `jest.config.js` to enable ESM usage in `ts-jest`.
- Removed Jest configuration from `package.json` as it is now centralized in `jest.config.js`.
- Added a helper function to retrieve error messages that accommodates different Node.js versions
- Updated error message assertions to check for both message prefixes and specific error codes
Modified the promise resolution in the TestServer class to explicitly resolve with undefined instead of no arguments
@daniyelnnr daniyelnnr requested review from a team and Copilot September 11, 2025 17:07
@daniyelnnr daniyelnnr self-assigned this Sep 11, 2025
@daniyelnnr daniyelnnr requested review from arturpimentel and removed request for a team September 11, 2025 17:07
@daniyelnnr daniyelnnr requested review from silvadenisaraujo and removed request for arturpimentel September 11, 2025 17:08
@daniyelnnr daniyelnnr requested a review from filafb September 11, 2025 17:08
Copy link

@Copilot Copilot AI left a comment

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 fixes CI pipeline issues by updating dependencies, fixing linting errors, and improving test compatibility across Node.js versions.

  • Updated Jest and ts-jest to newer versions with proper ESM configuration
  • Disabled problematic TSLint object literal sorting rules
  • Enhanced error handling in axios tracing tests for better Node.js version compatibility

Reviewed Changes

Copilot reviewed 22 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tslint.json Disabled object-literal-sort-keys rule to fix linting failures
package.json Updated Jest to v29.7.0 and ts-jest to v29.1.0, added linting to build script
src/utils/buildFullPath.ts Fixed semicolon inconsistencies and equality operators
src/service/worker/runtime/graphql/schema/schemaDirectives/Auth.ts Changed loose equality to strict equality operators
Multiple telemetry/metrics files Fixed semicolon inconsistencies and import ordering
Test files Enhanced error handling for Node.js version compatibility
Various source files Fixed trailing commas and semicolon consistency issues

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


function parseArgs (authArgs: AuthDirectiveArgs): AuthDirectiveArgs {
if (authArgs.scope == 'PUBLIC') {
if (authArgs.scope === 'PUBLIC') {
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Good improvement changing from loose equality (==) to strict equality (===) operators. This prevents type coercion issues and follows TypeScript best practices.

Copilot uses AI. Check for mistakes.

field.resolve = async (root, args, ctx, info) => {
const authArgs = parseArgs(this.args as AuthDirectiveArgs)
if (!authArgs.scope || authArgs.scope == 'PRIVATE') {
if (!authArgs.scope || authArgs.scope === 'PRIVATE') {
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Good improvement changing from loose equality (==) to strict equality (===) operators. This prevents type coercion issues and follows TypeScript best practices.

Copilot uses AI. Check for mistakes.

Comment on lines +35 to +43
const getErrorMessage = (error: AxiosError, expectedPrefix: string): string => {
// In Node.js 20+, message might be empty, check errors array
const errorWithErrors = error as any
if (!error.message && errorWithErrors.errors && errorWithErrors.errors.length > 0) {
// Find the error that matches our expected prefix
const matchingError = errorWithErrors.errors.find((err: any) =>
err.message && err.message.startsWith(expectedPrefix)
)
return matchingError ? matchingError.message : error.message
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The error handling compatibility function is well-implemented, but consider adding proper TypeScript types instead of using 'any'. Define an interface for the expected error structure to improve type safety.

Suggested change
const getErrorMessage = (error: AxiosError, expectedPrefix: string): string => {
// In Node.js 20+, message might be empty, check errors array
const errorWithErrors = error as any
if (!error.message && errorWithErrors.errors && errorWithErrors.errors.length > 0) {
// Find the error that matches our expected prefix
const matchingError = errorWithErrors.errors.find((err: any) =>
err.message && err.message.startsWith(expectedPrefix)
)
return matchingError ? matchingError.message : error.message
interface ErrorWithErrorsArray extends AxiosError {
errors?: { message?: string }[]
}
const getErrorMessage = (error: AxiosError, expectedPrefix: string): string => {
// In Node.js 20+, message might be empty, check errors array
const errorWithErrors = error as ErrorWithErrorsArray
if (!error.message && errorWithErrors.errors && errorWithErrors.errors.length > 0) {
// Find the error that matches our expected prefix
const matchingError = errorWithErrors.errors.find(
(err) => err.message && err.message.startsWith(expectedPrefix)
)
return matchingError ? matchingError.message! : error.message

Copilot uses AI. Check for mistakes.


// Check if error message starts with prefix OR if it's empty but we have the expected error code
const hasExpectedPrefix = errorMessage && errorMessage.startsWith(expectedPrefix)
const hasExpectedCode = !errorMessage && (error as AxiosError).code === 'ECONNREFUSED'
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded 'ECONNREFUSED' error code should be extracted to a constant or made configurable to improve maintainability and make the test expectations more explicit.

Copilot uses AI. Check for mistakes.

Base automatically changed from update/semconv to master September 26, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant