Skip to content

✨ Quality: Fix snippet_output validation when execution is disabled#871

Open
hieuit095 wants to merge 2 commits intomfontanini:masterfrom
hieuit095:contribai/improve/quality/fix-snippet-output-validation-when-execu
Open

✨ Quality: Fix snippet_output validation when execution is disabled#871
hieuit095 wants to merge 2 commits intomfontanini:masterfrom
hieuit095:contribai/improve/quality/fix-snippet-output-validation-when-execu

Conversation

@hieuit095
Copy link
Copy Markdown

Problem

The snippet_output comment handler validates that the referenced snippet ID exists. However, when execution is disabled (no -x flag), code blocks with +id attributes still need to register their IDs so they can be referenced by <!-- snippet_output: foo -->. The issue is that the ID registration might be skipped or validated too early when execution is disabled.

Severity: high
File: src/presentation/builder/comment.rs

Solution

In the push_code method of PresentationBuilder (in snippet.rs), when processing a snippet with an ID attribute, the ID should be registered even when execution is disabled. Currently, if is_execution_allowed() returns false, the ID registration might be skipped or handled differently.

Changes

  • src/presentation/builder/snippet.rs (modified)
  • src/presentation/builder/mod.rs (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Closes #870

…is disabled

The `snippet_output` comment handler validates that the referenced snippet ID exists. However, when execution is disabled (no `-x` flag), code blocks with `+id` attributes still need to register their IDs so they can be referenced by `<!-- snippet_output: foo -->`. The issue is that the ID registration might be skipped or validated too early when execution is disabled.

Affected files: snippet.rs, mod.rs

Signed-off-by: hieuit095 <[email protected]>
…is disabled

The `snippet_output` comment handler validates that the referenced snippet ID exists. However, when execution is disabled (no `-x` flag), code blocks with `+id` attributes still need to register their IDs so they can be referenced by `<!-- snippet_output: foo -->`. The issue is that the ID registration might be skipped or validated too early when execution is disabled.

Affected files: snippet.rs, mod.rs

Signed-off-by: hieuit095 <[email protected]>
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.

bug: error: snippet id foo not defined when not running with -x

1 participant