microsoft / microsoft/vscode

Feature: Enhance parameter validation and whitespace sanitization in azure-pipeline.ts skill

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

Description

### Summary
Introduce a robust parameter validation and sanitization helper (`validateAndSanitizeParam`) in `src/vs/.github/skills/azure-pipelines/azure-pipeline.ts` to prevent empty values and handle whitespace issues cleanly.

### Problem
Azure DevOps pipeline automation scripts can encounter silent failures or unexpected behavior if configuration constants or CLI arguments contain trailing/leading whitespace or missing values.

### Proposed Solution
1. Add a dedicated validation and sanitization utility function that verifies data types, checks for empty strings, and trims whitespace automatically.
2. Apply this validation to critical pipeline parameters (`ORGANIZATION`, `PROJECT`, `DEFAULT_DEFINITION_ID`, etc.) to ensure early failure with explicit error codes if inputs are invalid.

### Code Example
```typescript
function validateAndSanitizeParam(value: string | undefined, paramName: string): string {
if (!value || typeof value !== 'string' || value.trim() === '') {
console.error(`[Pipeline Error] Required parameter '${paramName}' is missing, empty, or invalid.`);
process.exit(1);
}
return value.trim();
}

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.