Skip to content

[Feature] Incorrect type validation in ConfigurationReader.readObject allows all value types to pass #3063

Open

Description

@ZhiyanJia

Description

ConfigurationReader.readObject() is intended to validate object values and throw ExpectedObjectValue when validation fails.

However, its current isObject() condition evaluates to true for every value, allowing non-object values to pass validation.

Relevant code

In src/common/configurationReader.ts:

public static readObject(value: any): Record<string, any> {
    if (this.isObject(value)) {
        return value;
    }
    throw ErrorHelper.getInternalError(InternalErrorCode.ExpectedObjectValue, value);
}

private static isObject(value: any): boolean {
    return typeof value === "object" || !ConfigurationReader.isArray(value);
}

The condition covers every value:

  • Arrays pass because typeof [] === "object".
  • Every non-array value passes because !Array.isArray(value) is true.

As a result, the ExpectedObjectValue error branch is never reached.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions