Commit 533fe37
committed
Error when buf.yaml dep is missing from buf.lock
When a module is added to buf.yaml deps but buf dep update has not been
run, the module is absent from buf.lock entirely. Previously this caused
two bad outcomes depending on whether any proto files imported from the
missing dep:
- If proto files imported from it: a confusing protoc-level "file not
found" error with no mention of buf.lock or what to do.
- If proto files did not yet import from it: MalformedDepsForWorkspace
would flag it as MalformedDepTypeUnused, suggesting the user remove
the dep — the opposite of the right advice.
Fix this by checking, during workspace construction, that every module
declared in buf.yaml deps has a corresponding entry in buf.lock. If any
are missing, return an actionable error immediately:
"buf.testing/acme/extension" declared in buf.yaml deps but not present
in buf.lock; run "buf dep update" to update the lock file
The check is added to both the v1 and v2 workspace construction paths
in workspace_provider.go and requires no network call — it is a pure
comparison of module full names between the two config files.
Two test cases are added: one where the missing dep is not yet used in
any proto file (previously: silent success with a misleading "unused"
warning), and one where the missing dep is actively imported (previously:
cryptic "file not found" from the compiler).1 parent 54e9748 commit 533fe37
8 files changed
Lines changed: 159 additions & 0 deletions
File tree
- private/buf/bufworkspace
- testdata/basic
- workspace_dep_missing_from_lock_used
- finance/bond/proto/acme/bond/v2
- workspace_dep_missing_from_lock
- finance/bond/proto/acme/bond/v2
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| 327 | + | |
| 328 | + | |
326 | 329 | | |
327 | 330 | | |
328 | 331 | | |
| |||
356 | 359 | | |
357 | 360 | | |
358 | 361 | | |
| 362 | + | |
359 | 363 | | |
360 | 364 | | |
361 | 365 | | |
362 | 366 | | |
363 | 367 | | |
364 | 368 | | |
365 | 369 | | |
| 370 | + | |
366 | 371 | | |
367 | 372 | | |
368 | 373 | | |
| |||
386 | 391 | | |
387 | 392 | | |
388 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
389 | 397 | | |
390 | 398 | | |
391 | 399 | | |
| |||
410 | 418 | | |
411 | 419 | | |
412 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
413 | 426 | | |
414 | 427 | | |
415 | 428 | | |
| |||
438 | 451 | | |
439 | 452 | | |
440 | 453 | | |
| 454 | + | |
441 | 455 | | |
442 | 456 | | |
443 | 457 | | |
| |||
465 | 479 | | |
466 | 480 | | |
467 | 481 | | |
| 482 | + | |
468 | 483 | | |
469 | 484 | | |
470 | 485 | | |
| |||
502 | 517 | | |
503 | 518 | | |
504 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
505 | 523 | | |
506 | 524 | | |
507 | 525 | | |
| |||
518 | 536 | | |
519 | 537 | | |
520 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
521 | 544 | | |
522 | 545 | | |
523 | 546 | | |
| |||
578 | 601 | | |
579 | 602 | | |
580 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
581 | 617 | | |
582 | 618 | | |
583 | 619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
250 | 328 | | |
251 | 329 | | |
252 | 330 | | |
| |||
0 commit comments