@@ -87,11 +87,13 @@ class MainModel(LolbasModel):
8787
8888
8989if __name__ == "__main__" :
90+ def escaper (x ): return x .replace ('%' , '%25' ).replace ('\r ' , '%0D' ).replace ('\n ' , '%0A' )
91+
9092 yaml_files = glob .glob ("yml/**" , recursive = True )
9193
9294 if not yaml_files :
9395 print ("No YAML files found under 'yml/**'." )
94- sys .exit (1 )
96+ sys .exit (- 1 )
9597
9698 has_errors = False
9799 for file_path in yaml_files :
@@ -105,13 +107,14 @@ class MainModel(LolbasModel):
105107 print (f"❌ Validation error in { file_path } :\n { ve } \n " )
106108 for err in ve .errors ():
107109 # GitHub Actions error format
110+ print (err )
108111 path = '.' .join ([str (x ) for x in err .get ('loc' , [None ])])
109112 msg = err .get ('msg' , 'Unknown validation error' )
110- print (f"::error file=/ { file_path } ,line=1,title=Schema error::' { msg } ' for { path } " )
113+ print (f"::error file={ file_path } ,line=1,title={ escaper ( err . get ( 'type' ) or 'Validation error' ) } :: { escaper ( msg ) } : { escaper ( path ) } " )
111114 has_errors = True
112115 except Exception as e :
113116 print (f"⚠️ Error processing { file_path } : { e } \n " )
114- print (f"::error file=/ { file_path } ,line=1,title=Processing error::Error processing file: { e } " )
117+ print (f"::error file={ file_path } ,line=1,title=Processing error::Error processing file: { escaper ( e ) } " )
115118 has_errors = True
116119
117- sys .exit (1 if has_errors else 0 )
120+ sys .exit (- 1 if has_errors else 0 )
0 commit comments