Commit cf9992e
fix: handle invalid YAML in existing dependabot config gracefully (#526)
* fix: return None instead of re-raising on invalid YAML in existing dependabot config
Fixes #523
## What
Changed build_dependabot_file() to return None instead of re-raising when an existing dependabot config has invalid YAML (e.g., duplicate keys, indentation errors). Updated existing test expectations and added a new test for the duplicate key scenario reported in the issue.
## Why
When a repository had an invalid dependabot.yml (such as a duplicate key), the YAML parse error crashed the entire program, preventing all remaining repositories from being processed. Returning None allows the caller's existing `if dependabot_file is None` check to skip the repo and continue.
## Notes
- The error message is still printed via the existing `print(f"YAML indentation error: {e}")` so users can identify which repo has a broken config.
- The second test at line 175 (indentation error) also changed from `assertRaises` to `assertIsNone` since it exercises the same code path.
Signed-off-by: jmeridth <jmeridth@gmail.com>
* fix: move None guard above yaml.dump to avoid writing null to debug file
## What
Moved the `if dependabot_file is None` check above the `yaml.dump()` call in `main()` so that None results skip immediately without writing `null` to `dependabot-output.yaml`.
## Why
The previous ordering called `yaml.dump(None, yaml_file)` before checking for None, writing a `null` YAML literal to the debug artifact. This was a pre-existing issue for the "no package managers" path, but the YAML error handling change made it newly reachable via the error path.
## Notes
- The YAML object and stream setup also moved below the guard since they're only needed when dependabot_file is not None.
Signed-off-by: jmeridth <jmeridth@gmail.com>
* fix: Update dependabot_file.py
Co-authored-by: Zack Koppert <zkoppert@github.com>
Signed-off-by: Jason Meridth <jmeridth@gmail.com>
* fix: restore return None and remove duplicate print in YAML error handler
The UI merge of the error message suggestion accidentally replaced
`return None` with the new print line, leaving two print statements
and no early return. This caused UnboundLocalError on repos with
invalid YAML configs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: jmeridth <jmeridth@gmail.com>
* fix: use generic "Skipping repository" message when dependabot_file is None
## What
Change the print message from "No (new) compatible package manager found" to "Skipping repository" when `build_dependabot_file()` returns `None`.
## Why
`build_dependabot_file()` now returns `None` for two distinct reasons: no compatible package managers found, and a YAML parse error. The old message was only accurate for the first case and misleading for the second. Since the YAML error is already printed just before this point, a generic message avoids false attribution.
Signed-off-by: jmeridth <jmeridth@gmail.com>
---------
Signed-off-by: jmeridth <jmeridth@gmail.com>
Signed-off-by: Jason Meridth <jmeridth@gmail.com>
Co-authored-by: Zack Koppert <zkoppert@github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 2fe6476 commit cf9992e
3 files changed
+33
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
254 | | - | |
| 253 | + | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
| |||
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
134 | 157 | | |
135 | 158 | | |
136 | 159 | | |
| |||
152 | 175 | | |
153 | 176 | | |
154 | 177 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
159 | 182 | | |
160 | 183 | | |
161 | 184 | | |
| |||
0 commit comments