microsoft / microsoft/vscode

Add validation checks to BasePolicy constructor for robust error handling

Open
#333,852 0 comments 0 reactions 1 assignee Claimed by @pwang347 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

## Problem / Motivation
Currently, the `BasePolicy` abstract class initializes its properties without validating input parameters. If invalid, empty, or malformed parameters (such as an incorrect `minimumVersion` format or missing critical fields) are passed by derived classes, it can lead to runtime issues or unexpected behaviors later in the rendering pipeline.

## Proposed Solution
- Add defensive validation checks inside the `BasePolicy` constructor.
- Validate that mandatory fields (`type`, `name`, `category`, `description`, `moduleName`) are provided and correctly typed.
- Implement a regex check on `minimumVersion` to ensure proper semantic version formatting.
- Throw descriptive `Error` instances immediately upon receiving invalid initialization arguments to ease debugging.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.