Skip to content

Empty exported interface fails with “unknown component 1: component index out of bounds” #252

Closed

Description

@mandesero

An empty exported interface causes componentize-py to fail during component generation.

Environment:

  • componentize-py 0.25.1
  • Python 3.13.3
  • macOS arm64

Minimal reproduction:

package example:empty;

interface marker {}

world empty {
    export marker;
}
$ componentize-py -d world.wit -w empty bindings .
# app.py
from wit_world import exports

class Marker(exports.Marker):
    pass
$ componentize-py -d world.wit -w empty componentize \
    --python-path . app -o app.wasm

Expected: compilation succeeds and produces a valid component exporting the empty marker interface.

Actual: the command exits with status 1:

AssertionError:

Caused by:
    unknown component 1: component index out of bounds (at offset 0xa17228)

Adding an ordinary function export alongside marker does not prevent the failure. Adding a record type inside marker allows compilation to succeed.

Suspected cause: componentize-py 0.25.1 depends on component-init-transform 0.2.0. In its instrument() and initialize() functions, the nested-component copying loops stop when a section range reaches unchecked_range.end. An empty nested component has no section payload before End, so the loop appears to consume the following outer section instead.

Activity

  1. dicej commented on Oct 27, 2026

    @dicej
    Collaborator

    Thanks for reporting this, @mandesero. I'll investigate when I get a chance, hopefully by the end of this week.

  2. mandesero commented on Oct 27, 2026

    @mandesero
    Author

    Thanks, @dicej!

    While testing componentize-py 0.25.1, I found two more issues:

    1. Repeated bindings generation fails

    Running componentize-py -d world.wit -w calc bindings . twice with a non-empty exported interface fails on the second run with AssertionError: File exists (os error 17). Removing wit_world/exports fixes it. Direct world-level function exports work fine.

    2. Empty resource generates invalid Python

    For:

    interface handles {
        resource token;
    }
    
    world opaque {
        export handles;
    }

    Generated wit_world/exports/handles.py contains class Token(Protocol): without a body or pass, causing an IndentationError.

    Are these bugs or intentional limitations? If bugs, could you open separate issues for them?

  3. dicej commented on Oct 27, 2026

    @dicej
    Collaborator

    Thanks. I've opened #253 for item 1 and will look into item 2 when I investigate the original issue.

  4. added a commit that references this issue on Oct 28, 2026
    704719e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions