diff --git a/src/inputs.ts b/src/inputs.ts index 66b945fe..5dfcdc4a 100644 --- a/src/inputs.ts +++ b/src/inputs.ts @@ -963,7 +963,11 @@ export default class Inputs { 'sections', inputContext.sections ?? (this.config.get('sections') as ReadmeSection[]), ); - this.sections = this.config.get('sections') as ReadmeSection[]; + const configuredSections: unknown = this.config.get('sections'); + if (!Array.isArray(configuredSections) || !configuredSections.every((section: unknown) => typeof section === 'string')) { + throw new Error('Invalid sections configuration: expected an array of section names'); + } + this.sections = configuredSections as ReadmeSection[]; this.readmePath = inputContext.readmePath ?? path.resolve(this.config.get(ConfigKeys.pathsReadme) as string); this.readmeEditor = inputContext.readmeEditor ?? new ReadmeEditor(this.readmePath);