Skip to content

fix: support multiline world declarations in wash wit add#5295

Merged
ricochet merged 1 commit into
wasmCloud:mainfrom
immanuwell:fix/wit-add-multiline-world
Jun 30, 2026
Merged

fix: support multiline world declarations in wash wit add#5295
ricochet merged 1 commit into
wasmCloud:mainfrom
immanuwell:fix/wit-add-multiline-world

Conversation

@immanuwell

Copy link
Copy Markdown
Contributor

No linked issue, couldnt find a direct match.

wash wit add fails on valid world.wit files when the world opening brace is on the next line. It bails with Could not find a world block in world.wit to add the import, kinda rough.

This makes the import insertion logic handle both brace styles, keeps new imports after the last existing import, and adds regression tests for the helper plus the real command path.

Repro:

  1. Create wit/world.wit with:
package test:component@0.1.0;

world example
{
}
  1. Run wash wit add wasi:logging/logging@0.1.0-draft
  2. Before this fix it errors with Could not find a world block in world.wit to add the import
  3. With this fix the import is added inside the world block and the command keeps going

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell requested a review from a team as a code owner June 28, 2026 08:39
pending_world = true;
if trimmed.contains('{') {
pending_world = false;
let next_indent = lines

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.

could be a helper since used twice, but this is good


/// Test 1b: Add dependency when the world opening brace is on the next line
/// Verifies `wash wit add` handles valid multi-line world declarations
#[tokio::test]

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.

I think we can pair this one down to call insert_import_into_world(original_content, &import_line) directly. As a side benefit it would no longer need a tempdir or async file I/O, and can be converted to a plain #[test] and run in-memory.

@ricochet ricochet 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.

just left two nits. OK not to do those

@ricochet ricochet merged commit 62d38a6 into wasmCloud:main Jun 30, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants