Skip to content

[yaml] Better recovering for list entry without - prefix - #2427

Merged
sigurdm merged 4 commits into
dart-lang:mainfrom
FMorschel:yaml-parsing
Aug 4, 2026
Merged

sigurdm merged 4 commits into
dart-lang:mainfrom
FMorschel:yaml-parsing

Conversation

@FMorschel

Copy link
Copy Markdown
Contributor

This is a suggestion to fix:

Where we recover from a list item without the - prefix and give it a more coherent error message.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

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.

@FMorschel
FMorschel requested a review from a team as a code owner June 11, 2026 16:45

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@FMorschel

Copy link
Copy Markdown
Contributor Author

Can you take a look or assign someone, please, @nex3? Thanks a lot!

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

Package publishing

Package Version Status Publish tag (post-merge)
package:api_summary 0.1.0-wip WIP (no publish necessary)
package:bazel_worker 1.1.5 already published at pub.dev
package:benchmark_harness 2.4.0 already published at pub.dev
package:boolean_selector 2.1.2 already published at pub.dev
package:browser_launcher 1.2.0-wip WIP (no publish necessary)
package:cli_config 0.2.1-wip WIP (no publish necessary)
package:cli_util 0.5.1 already published at pub.dev
package:clock 1.1.3-wip WIP (no publish necessary)
package:code_builder 4.12.0-wip WIP (no publish necessary)
package:coverage 1.15.1 already published at pub.dev
package:csslib 1.0.2 already published at pub.dev
package:extension_discovery 2.1.0 already published at pub.dev
package:file 7.0.2-wip WIP (no publish necessary)
package:file_testing 3.1.0-wip WIP (no publish necessary)
package:glob 2.1.3 already published at pub.dev
package:graphs 2.4.0-wip WIP (no publish necessary)
package:html 0.15.7-wip WIP (no publish necessary)
package:io 1.1.0-wip WIP (no publish necessary)
package:json_rpc_2 4.1.0 already published at pub.dev
package:markdown 7.4.0 ready to publish markdown-v7.4.0
package:mime 2.1.0-wip WIP (no publish necessary)
package:oauth2 2.0.5 already published at pub.dev
package:package_config 3.0.0 already published at pub.dev
package:pool 1.5.3-wip WIP (no publish necessary)
package:process 5.0.5 (error) pubspec version (5.0.5) and changelog (5.0.6-wip) don't agree
package:pub_semver 2.2.0 already published at pub.dev
package:pubspec_parse 1.6.0-wip WIP (no publish necessary)
package:source_map_stack_trace 2.1.3-wip WIP (no publish necessary)
package:source_maps 0.10.14-wip WIP (no publish necessary)
package:source_span 1.10.2 already published at pub.dev
package:sse 4.2.0 already published at pub.dev
package:stack_trace 1.12.2-wip (error) pubspec version (1.12.2-wip) and changelog (1.12.2-dev) don't agree
package:stream_channel 2.1.4 already published at pub.dev
package:stream_transform 2.1.2-wip WIP (no publish necessary)
package:string_scanner 1.4.2-wip WIP (no publish necessary)
package:term_glyph 1.2.3-wip WIP (no publish necessary)
package:test_reflective_loader 0.6.0 ready to publish test_reflective_loader-v0.6.0
package:timing 1.0.2 already published at pub.dev
package:unified_analytics 8.0.15 already published at pub.dev
package:watcher 1.2.2-wip WIP (no publish necessary)
package:yaml 3.1.4-wip WIP (no publish necessary)
package:yaml_edit 2.2.4 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

PR Health

Unused Dependencies ✔️
Package Status
yaml ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
yaml None 3.1.3 3.1.4-wip 3.1.4-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

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.

Comment thread pkgs/yaml/lib/src/scanner.dart Resolved

@sigurdm sigurdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - just a small suggestion.

@FMorschel

Copy link
Copy Markdown
Contributor Author

Thanks, @sigurdm! Done.

@FMorschel FMorschel changed the title [yaml] better recovering for list entry without - prefix [yaml] Better recovering for list entry without - prefix Jun 15, 2026
@FMorschel

Copy link
Copy Markdown
Contributor Author

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?

@DanTup

DanTup commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

How does the rolling of this package into the Dart SDK work?

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 tools_rev which is currently 338a2c8:

https://github.com/dart-lang/sdk/blob/c9b0df8469a2cb58298dde065044df8eceaaae5f/DEPS#L152

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:

dart-lang/sdk@fe2141a

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.

@sigurdm
sigurdm requested a review from jonasfj June 29, 2026 07:55
_scanner.scan();
_states.add(_State.BLOCK_SEQUENCE_ENTRY);
return _parseNode(block: true);
}

@jonasfj jonasfj Jun 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

https://github.com/dart-lang/tools/pull/2427/changes#diff-cfd2bd97aae0a6765f4aad97f742cce898d78c68e78956bff4ad6d4c7ab87fe2R151-R158

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonasfj, is the above explanation enough for you to merge this, or do you need anything else from me?

@jonasfj jonasfj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@FMorschel

Copy link
Copy Markdown
Contributor Author

@jonasfj or @sigurdm, do you need anything else from me? Can we please land this? Thanks!

@jonasfj

jonasfj commented Jul 24, 2026

Copy link
Copy Markdown
Member

@sigurdm any reason we don't merge this when you're back?
(I think we're both currently out of office)

@sigurdm

sigurdm commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Sorry for delay. Merging now.

@sigurdm
sigurdm merged commit e79e9cc into dart-lang:main Aug 4, 2026
22 checks passed
@FMorschel
FMorschel deleted the yaml-parsing branch August 4, 2026 11:49
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 7, 2026
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]>
amanmaurya92 pushed a commit to amanmaurya92/dart-tools that referenced this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants