Skip to content

fix: use line-based heuristic for auto-export detection #46

Open
simongdavies wants to merge 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-export
Open

fix: use line-based heuristic for auto-export detection #46
simongdavies wants to merge 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-export

Conversation

@simongdavies
Copy link
Contributor

The naive .contains("export") check in register_handler() would false-positive on string literals (e.g. ''), comments (e.g. // TODO: export data), and identifiers (e.g. exportPath), skipping auto-export and causing handler registration to fail.

Replace with has_export_statement() which checks whether any source line starts with 'export' (after leading whitespace), correctly ignoring occurrences inside strings, comments, and variable names.

Closes #39

…ev#39)

The naive .contains("export") check in register_handler() would
false-positive on string literals (e.g. '<config mode="export">'),
comments (e.g. // TODO: export data), and identifiers (e.g. exportPath),
skipping auto-export and causing handler registration to fail.

Replace with has_export_statement() which checks whether any source line
starts with 'export' (after leading whitespace), correctly ignoring
occurrences inside strings, comments, and variable names.

Closes hyperlight-dev#39

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
@simongdavies simongdavies added bug Something isn't working kind/bugfix Bug fix and removed bug Something isn't working labels Mar 10, 2026
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

lgtm, it's not perfect but better than before for sure

// not the word "export" inside string literals, comments, or identifiers.

#[test]
fn handler_with_export_in_string_literal() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be unit tests instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

register_handler auto-export heuristic uses naive substring match — string literals containing "export" break handler registration

2 participants