@@ -47,12 +47,28 @@ interface ParsedProject {
4747// Helpers
4848// ---------------------------------------------------------------------------
4949async function fetchProjects ( yamlUrl : string ) : Promise < ParsedProject [ ] > {
50- const response = await fetch ( yamlUrl )
51- if ( ! response . ok ) {
52- throw new Error ( `Failed to fetch governance YAML (${ response . status } ): ${ yamlUrl } ` )
50+ let text : string
51+
52+ try {
53+ const response = await fetch ( yamlUrl )
54+
55+ if ( ! response . ok ) {
56+ throw new Error ( `HTTP ${ response . status } ${ response . statusText } ` )
57+ }
58+ text = await response . text ( )
59+ } catch ( err ) {
60+ throw new Error ( `Failed to fetch governance YAML from ${ yamlUrl } : ${ ( err as Error ) . message } ` )
61+ }
62+
63+ let data : GovernanceYaml
64+ try {
65+ data = yaml . load ( text ) as GovernanceYaml
66+ if ( ! data || typeof data !== 'object' ) {
67+ throw new Error ( 'Parsed YAML is not an object — file format may have changed' )
68+ }
69+ } catch ( err ) {
70+ throw new Error ( `Failed to parse governance YAML from ${ yamlUrl } : ${ ( err as Error ) . message } ` )
5371 }
54- const text = await response . text ( )
55- const data = yaml . load ( text ) as GovernanceYaml
5672
5773 return Object . entries ( data ) . map ( ( [ project , info ] ) => ( {
5874 project,
@@ -107,7 +123,15 @@ const job: IJobDefinition = {
107123 // 2. Fetch + parse the governance YAML
108124 // ------------------------------------------------------------------
109125 ctx . log . debug ( `Fetching governance YAML...` )
110- const projects = await fetchProjects ( source . yamlUrl )
126+ let projects : ParsedProject [ ]
127+
128+ try {
129+ projects = await fetchProjects ( source . yamlUrl )
130+ } catch ( err ) {
131+ ctx . log . error ( { err } , `Could not load governance YAML — skipping source` )
132+ continue
133+ }
134+
111135 ctx . log . debug ( `Parsed ${ projects . length } projects from YAML` )
112136
113137 // ------------------------------------------------------------------
0 commit comments