getappmap / appmap-node

AppMap client agent for Node.js
Other
9 stars 4 forks source link

Error: "ASYNC_OPTIONS_TYPE" is not supposed to be used as a value. #158

Closed dustinbyrne closed 1 month ago

dustinbyrne commented 1 month ago

via npm test in nestjs/nest

Test cases:

ConfigurableModuleBuilder
       setExtras
         should apply module definition transformer function and return typed builder

ConfigurableModuleBuilder
       setClassMethodName
         should set static class method name and return typed builder:

ConfigurableModuleBuilder
       setFactoryMethodName
         should set configuration factory class method name and return typed builder

ConfigurableModuleBuilder
       build
         should return a fully typed "ConfigurableModuleClass"

Exception:

     Error: "ASYNC_OPTIONS_TYPE" is not supposed to be used as a value.
      at Object.get (packages/common/module-utils/configurable-module.builder.ts:417:17)
      at isSimpleObject (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/parameter.ts:99:57)
      at parameterSchema (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/parameter.ts:93:12)
      at parameter (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/parameter.ts:9:42)
      at optParameter (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/parameter.ts:65:10)
      at makeReturnEvent (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/event.ts:38:31)
      at Recording.functionReturn (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/Recording.ts:55:34)
      at /Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/recorder.ts:85:17
      at Array.map (<anonymous>)
      at ConfigurableModuleBuilder.record (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/recorder.ts:84:37)
      at ConfigurableModuleBuilder.createTypeProxy (packages/common/module-utils/configurable-module.builder.ts:414:36)
      at ConfigurableModuleBuilder.<anonymous> (packages/common/module-utils/configurable-module.builder.ts:312:34)
      at ConfigurableModuleBuilder.record (/Users/ajp/.npm/_npx/c76987c9a3c183fa/node_modules/appmap-node/src/recorder.ts:81:24)
      at ConfigurableModuleBuilder.build (packages/common/module-utils/configurable-module.builder.ts:304:36)
      at Context.<anonymous> (packages/common/test/module-utils/configurable-module.builder.spec.ts:15:11)
      at processImmediate (node:internal/timers:483:21)
dustinbyrne commented 1 month ago

Summary of the Issue

High-Level Description of the Problem

The isSimpleObject function in the appmap-node package does not correctly handle sentinel values such as "ASYNC_OPTIONS_TYPE". This leads to an error when such values are passed into the function, as it incorrectly identifies these sentinel values as simple objects.

High-Level Plan for Fixing the Problem

  1. Enhance isSimpleObject Function:

    • Add conditions to the isSimpleObject function to check for and exclude sentinel values like "ASYNC_OPTIONS_TYPE".
    • This will prevent the function from misclassifying these sentinel values as simple objects and causing runtime errors.
  2. Update parameter Function and Relevant Callers:

    • Ensure the parameter function and corresponding logic are aligned to correctly propagate any necessary adjustments from isSimpleObject.
  3. Test Cases for Sentinel Values:

    • Add test cases to validate that sentinel values are correctly identified and excluded by the isSimpleObject function.
    • Ensure these test cases are generic and do not depend on downstream code.

Test Case Expected to Trigger the Problem

A test case that directly invokes the isSimpleObject function with a sentinel value to trigger the issue:

import { expect } from "chai";
import { isSimpleObject } from "../src/parameter";

describe("isSimpleObject", () => {
  it('should not treat "ASYNC_OPTIONS_TYPE" as a simple object', () => {
    const sentinelValue = "ASYNC_OPTIONS_TYPE";
    const result = isSimpleObject(sentinelValue);
    expect(result).to.be.false;
  });
});

This test case ensures that the sentinel value "ASYNC_OPTIONS_TYPE" is correctly identified as not being a simple object, thereby preventing the error.

appland-release commented 1 month ago

:tada: This issue has been resolved in version 2.23.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: