MCPcopy Create free account
hub / github.com/github/gh-aw / validateMaxCount

Function validateMaxCount

actions/setup/js/safe_output_validator.cjs:158–177  ·  view source on GitHub ↗

* Validate max count from environment variable with config fallback * @param {string|undefined} envValue - Environment variable value * @param {number|undefined} configDefault - Default from config.json * @param {number} [fallbackDefault] - Fallback default for testing (optional, defaults to 1)

(envValue, configDefault, fallbackDefault = 1)

Source from the content-addressed store, hash-verified

156 * @returns {{valid: true, value: number} | {valid: false, error: string}} Validation result
157 */
158function validateMaxCount(envValue, configDefault, fallbackDefault = 1) {
159 // Priority: env var > config.json > fallback default
160 // In production, config.json should always have the default
161 // Fallback is provided for backward compatibility and testing
162 const defaultValue = configDefault !== undefined ? configDefault : fallbackDefault;
163
164 if (!envValue) {
165 return { valid: true, value: defaultValue };
166 }
167
168 const parsed = parseInt(envValue, 10);
169 if (isNaN(parsed) || parsed < 1) {
170 return {
171 valid: false,
172 error: `Invalid max value: ${envValue}. Must be a positive integer`,
173 };
174 }
175
176 return { valid: true, value: parsed };
177}
178
179module.exports = {
180 loadSafeOutputsConfig,

Callers 1

processSafeOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected