Skip to content

[builders] Valid use step directives are missed after raw backticks #3900

Closed

Description

@alaney2

Bug

@workflow/builders 4.1.10 can report hasUseStep: false for a valid use step directive when a raw triple-backtick sequence appears earlier in the file and a template literal appears after the directive.

Minimal reproduction

// Markdown fence marker: ```
export async function brokenStep() {
  "use step";
  return `ok`;
}

The same result occurs when the first line is a regex literal:

const openFence = /```/;

export async function brokenStep() {
  "use step";
  return `ok`;
}

Run the detector:

import { readFileSync } from "node:fs";
import { detectWorkflowPatterns } from "@workflow/builders";

const source = readFileSync("step.ts", "utf8");
console.log(detectWorkflowPatterns(source));

Actual

{
  hasUseWorkflow: false,
  hasUseStep: false,
  hasDirective: false,
  hasSerde: false
}

Expected

hasUseStep should be true. Comments and regex literals elsewhere in the file should not affect directive discovery.

Notes

The current detector masks template-literal-looking spans before masking comments. The template-literal regex runs against raw source, so it can pair backticks from comments or regex literals with a later template literal and mask the real directive between them.

Please add regression cases for both examples above.

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