Repository navigation
[yaml] Better recovering for list entry without - prefix - #2427
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves error recovery and messaging when parsing YAML block sequences with list elements missing the '- ' prefix. It introduces tracking of token types at each indentation level in the scanner (_indentTypes) to detect if a missing colon error occurs within a block sequence, appending a helpful hint to the error message. The parser is also updated to handle the recovered key token as a sequence entry, and a test case has been added to verify this behavior. There are no review comments, so no further feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Can you take a look or assign someone, please, @nex3? Thanks a lot! |
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthUnused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with
API leaks
|
| Package | Leaked API symbol | Leaking sources |
|---|---|---|
| yaml | ErrorListener | yaml/yaml.dart::loadYaml::errorListener yaml/yaml.dart::loadYamlNode::errorListener yaml/yaml.dart::loadYamlDocument::errorListener |
| yaml | ScalarEvent | yaml_node.dart::YamlScalar::internal::scalar |
| yaml | EventType | event.dart::Event::type event.dart::EventType::streamStart event.dart::EventType::streamEnd event.dart::EventType::documentStart event.dart::EventType::documentEnd event.dart::EventType::alias event.dart::EventType::scalar event.dart::EventType::sequenceStart event.dart::EventType::sequenceEnd event.dart::EventType::mappingStart event.dart::EventType::mappingEnd event.dart::EventType::values event.dart::Event::new::type event.dart::ScalarEvent::type |
This check can be disabled by tagging the PR with skip-leaking-check.
Changelog Entry ✔️
| Package | Changed Files |
|---|
Changes to files need to be accounted for in their respective changelogs.
This check can be disabled by tagging the PR with skip-changelog-check.
Coverage ✔️
| File | Coverage |
|---|---|
| pkgs/yaml/lib/src/parser.dart | 💚 94 % ⬆️ 0 % |
| pkgs/yaml/lib/src/scanner.dart | 💚 95 % ⬆️ 0 % |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
| Files |
|---|
| no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
| Files |
|---|
| pkgs/bazel_worker/benchmark/benchmark.dart |
| pkgs/coverage/lib/src/coverage_options.dart |
| pkgs/html/example/main.dart |
| pkgs/pubspec_parse/test/git_uri_test.dart |
| pkgs/watcher/test/custom_watcher_factory_test.dart |
This check can be disabled by tagging the PR with skip-license-check.
sigurdm
left a comment
There was a problem hiding this comment.
Nice - just a small suggestion.
|
Thanks, @sigurdm! Done. |
- prefix- prefix
|
I have a question. How does the rolling of this package into the Dart SDK work? Because I have a CL open (https://dart-review.googlesource.com/c/sdk/+/511260/1..2), which mentions the issue this fixes. How does this get rolled into the SDK if that test will start to fail if we remove the annotation before this lands, and will fail if this lands with the annotation there? |
I don't know how up-to-date my knowledge is, but my understanding is: Versions of external packages in the SDK are controlled by the DEPS file. For packages from this repo (tools), they are all controlled together by There's a script in the SDK tools/rev_sdk_deps.dart that automates bumping those versions and producing a commit message that includes a summary of the changes it's bringing in, and here's an example commit: So after this PR lands, that script could be used to produce a change, and the annotation removed in the same CL. When I've done this in the past, to avoid the CL being a noisy mix of dep revs and a functional change, I've selectively only included the one package update and made the commit message clear. |
| _scanner.scan(); | ||
| _states.add(_State.BLOCK_SEQUENCE_ENTRY); | ||
| return _parseNode(block: true); | ||
| } |
There was a problem hiding this comment.
This is entirely orthogonal to the changes in scanner.dart, except that now the scanner will most likely report the thing about how it expected a '-'.
And because if this, we are not okay using the token it insert to do some recovery? Instead of throwing YamlException?
There was a problem hiding this comment.
We can't be sure that is what the user meant to do. I read the documentation for yaml just to work on this change, so I'm not an expert, but from what I could gather, the user could still be trying to write a key one indentation before the list but got the indentation wrong.
This part merely resolves this by considering it a list entry and stops us from throwing the YamlException below if we are recovering. If we are not recovering, the exception in scanner.dart will flow all the way up.
See:
There was a problem hiding this comment.
@jonasfj, is the above explanation enough for you to merge this, or do you need anything else from me?
jonasfj
left a comment
There was a problem hiding this comment.
I'm not 100% sure how all of this works 🙈
But at the top of my head, this looks reasonably safe, I won't block it.
|
@sigurdm any reason we don't merge this when you're back? |
|
Sorry for delay. Merging now. |
Revisions updated by `dart tools/rev_sdk_deps.dart`. core (https://github.com/dart-lang/core/compare/fe516ee..4a5ae2b): 4a5ae2bc Wed Aug 5 15:49:08 2026 +0000 dependabot[bot] Bump the github-actions group with 4 updates (dart-lang/core#988) 30363b90 Wed Aug 5 17:37:07 2026 +0200 Moritz Add skip-changelog-check label to dependabot PRs (dart-lang/core#987) ef697b97 Wed Aug 5 08:23:09 2026 +0200 dependabot[bot] Bump the github-actions group across 1 directory with 3 updates (dart-lang/core#983) 95bf1b9d Wed Aug 5 08:21:09 2026 +0200 Moritz Add pub dependabot support (dart-lang/core#986) b0400198 Tue Aug 4 18:48:31 2026 +0200 Moritz Replace permissions: read-all with permissions: contents: read in workflows (dart-lang/core#985) e1b0a677 Mon Aug 3 17:51:19 2026 +0200 Moritz Pin actions/checkout (dart-lang/core#984) dartdoc (https://github.com/dart-lang/dartdoc/compare/ac96918..1fd02f7): 1fd02f73 Sat Aug 1 18:52:23 2026 +0000 dependabot[bot] Bump the github-actions group with 3 updates (dart-lang/dartdoc#4276) ecosystem (https://github.com/dart-lang/ecosystem/compare/edfdb3b..ed9c592): ed9c592 Wed Aug 5 15:19:24 2026 +0200 Sigurd Meldgaard Support pull requests from forks and custom branches in CI workflows (dart-lang/ecosystem#440) d8c8a4c Wed Aug 5 13:09:39 2026 +0200 Sigurd Meldgaard Support configurable tag prefix in firehose and publish.yaml (dart-lang/ecosystem#436) http (https://github.com/dart-lang/http/compare/5d94ef5..9cb80c7): 9cb80c7 Wed Aug 5 16:32:40 2026 -0700 Nate Bosch Undeprecate the withCredentials field (dart-lang/http#1962) 44496f4 Mon Aug 3 20:58:34 2026 +0300 Melih Arık doc(http_profile): fix broken code examples in header setter docs (dart-lang/http#1954) 49ddf11 Mon Jul 20 21:08:18 2026 +0300 Ellet docs(readme): add close method override in UserAgentClient example (dart-lang/http#1949) fe4aaa9 Tue Jul 14 11:25:42 2026 -0700 Nate Bosch Switch to feature version bump (dart-lang/http#1953) 664fe06 Mon Jul 13 22:08:59 2026 +0200 Maurice Raguse Support for configuring the browser `fetch` credentials mode in `BrowserClient`. (dart-lang/http#1937) shelf (https://github.com/dart-lang/shelf/compare/6918a76..fb3f931): fb3f931 Sat Aug 1 20:01:06 2026 +0000 dependabot[bot] Bump the github-actions group with 4 updates (dart-lang/shelf#537) test (https://github.com/dart-lang/test/compare/4838365..dd426d4): dd426d43 Tue Aug 4 15:46:52 2026 -0700 Nate Bosch Obfuscate the test runner connection for VM and Node tests (dart-lang/test#2704) tools (https://github.com/dart-lang/tools/compare/b827a6e..f3ec9ed): f3ec9ed5 Wed Aug 5 16:36:58 2026 +0000 dependabot[bot] Bump the github-actions group across 1 directory with 8 updates (dart-lang/tools#2496) 6dac7b1f Wed Aug 5 17:37:23 2026 +0200 Moritz Add skip-changelog-check label to dependabot PRs (dart-lang/tools#2495) f16493da Wed Aug 5 08:11:23 2026 +0000 dependabot[bot] Bump analyzer from 10.2.0 to 14.1.0 in /pkgs/graphs (dart-lang/tools#2493) 7f33666d Wed Aug 5 08:21:24 2026 +0200 Moritz Add pub dependabot support (dart-lang/tools#2492) 1e3aac17 Tue Aug 4 18:52:43 2026 +0200 Moritz Replace permissions: read-all with permissions: contents: read in workflows (dart-lang/tools#2490) e79e9cc4 Tue Aug 4 08:47:01 2026 -0300 Felipe Morschel [yaml] Better recovering for list entry without `- ` prefix (dart-lang/tools#2427) ca89367d Mon Aug 3 17:50:48 2026 +0200 Moritz ci: pin unpinned GitHub Actions references to commit SHAs (dart-lang/tools#2487) 0da8d930 Mon Aug 3 10:48:16 2026 +0200 Moritz Update CODEOWNERS with global fallback and missing packages (dart-lang/tools#2469) 28396db2 Mon Aug 3 09:34:24 2026 +0200 Moritz [test_reflective_loader] Ignore unreachable_from_main in test files (dart-lang/tools#2486) 168a6e13 Mon Aug 3 08:28:27 2026 +0200 Morgan :) source_maps: check bounds earlier. (dart-lang/tools#2483) 27756a9b Fri Jul 31 17:37:37 2026 +0100 Danny Tuppeny [test_reflective_loader] Don't add setUp/tearDown if not defined, and provide correct locations (dart-lang/tools#2341) web (https://github.com/dart-lang/web/compare/12a9ca2..f1b9d56): f1b9d56 Sat Aug 1 19:43:21 2026 +0000 dependabot[bot] Bump the github-actions group with 3 updates (dart-lang/web#566) [email protected] Change-Id: Id362bbe87d302cfb6a1b6618de12c67be72f1855 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/532380 Commit-Queue: Nate Bosch <[email protected]> Reviewed-by: Brian Quinlan <[email protected]>
This is a suggestion to fix:
-prefix #2426Where we recover from a list item without the
-prefix and give it a more coherent error message.Contribution guidelines:
dart format.Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
Note: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer.