File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
scripts/known_good/models Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 3131 uses : actions/checkout@v4.2.2
3232 - name : Check
3333 run : |
34- ls -la
3534 scripts/known_good/update_module_from_known_good.py --known known_good.json --output-dir-modules bazel_common
3635 if git diff --quiet; then
3736 echo "No changes"
Original file line number Diff line number Diff line change @@ -95,8 +95,24 @@ def load_known_good(path: Path) -> KnownGood:
9595 """
9696
9797 with open (path , "r" , encoding = "utf-8" ) as f :
98- data = json .load (f )
99-
98+ text = f .read ()
99+ try :
100+ data = json .loads (text )
101+ except json .JSONDecodeError as e :
102+ lines = text .splitlines ()
103+ line = lines [e .lineno - 1 ] if 0 <= e .lineno - 1 < len (lines ) else ""
104+ pointer = " " * (e .colno - 1 ) + "^"
105+
106+ hint = ""
107+ if "Expecting value" in e .msg :
108+ hint = "Possible causes: trailing comma, missing value, or extra comma."
109+
110+ raise ValueError (
111+ f"Invalid JSON at line { e .lineno } , column { e .colno } \n "
112+ f"{ line } \n { pointer } \n "
113+ f"{ e .msg } . { hint } "
114+ ) from None
115+
100116 if not isinstance (data , dict ) or not isinstance (data .get ("modules" ), dict ):
101117 raise ValueError (
102118 f"Invalid known_good.json at { path } (expected object with 'modules' dict)"
You can’t perform that action at this time.
0 commit comments