Skip to content

fix(worker): expose workflow variables in HTTP step conditions fixes NV-8772 - #12675

Open
nikitagrossman wants to merge 3 commits into
nextfrom
nv-8772-http-step-does-not-have-access-to-workflow-variables-in-step
Open

nikitagrossman wants to merge 3 commits into
nextfrom
nv-8772-http-step-does-not-have-access-to-workflow-variables-in-step

Conversation

@nikitagrossman

@nikitagrossman nikitagrossman commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

What changed

HTTP Request steps now evaluate dashboard skip conditions against the same workflow namespace as every other step type. workflow.workflowId also starts resolving on the Framework path.

Why

HTTP Request is the only step type that evaluates controlValues.skip locally in the worker. Its compile context omitted workflow, so conditions like workflow.name equals Pawan compared against undefined and the activity feed showed evaluatedValues: {}.

Channel, digest, delay, and throttle steps already get workflow from ConstructFrameworkWorkflow, but that object is the raw Mongo entity and has no workflowId field — the dashboard picker advertises workflow.workflowId as the trigger identifier.

How

  • Shared buildWorkflowVariables() spreads the workflow entity and maps triggers[0].identifierworkflowId.
  • HTTP step resolves the workflow once, then uses it for control-value lookup and skip/Liquid compile context.
  • Framework fullPayloadForRender.workflow goes through the same helper.
flowchart TD
  Cond["Dashboard skip condition"] --> Type{"Step type"}
  Type -->|"email, in-app, sms, chat, push, throttle"| Bridge["SendMessage to bridge"]
  Type -->|"digest, delay"| AddJob["AddJob to bridge"]
  Type -->|"http_request"| Local["ExecuteHttpRequestStep evaluateRules"]
  Bridge --> Helper["buildWorkflowVariables"]
  AddJob --> Helper
  Local --> Helper
  Helper --> Ctx["workflow.name, workflow.workflowId, ..."]
Loading

Test plan

  • HTTP step skip on matching / non-matching workflow.name
  • HTTP step skip on workflow.workflowId (trigger identifier)
  • Activity evaluatedValues is populated instead of {}
  • {{ workflow.name }} compiles in the HTTP request body
  • Framework skip on workflow.workflowId for channel steps
  • buildWorkflowVariables unit spec

Out of scope

  • Legacy v0 step.filters evaluated by ConditionsFilter still have no workflow namespace.
  • Digest/delay re-evaluate dashboard skip only at scheduling time (AddJob), not after the wait window.

Fixes NV-8772

Made with Cursor

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

What we checked:

  • Private workflow fields stay hidden: No. buildWorkflowVariables returns only the five dashboard fields, and the HTTP step uses that result as its workflow value.

Summary

HTTP Request steps now expose the same filtered workflow variables as other step types when checking skip rules and rendering request bodies. A shared helper maps the first trigger identifier to workflow.workflowId, so both worker and Framework paths use the same workflow namespace. Major changes: HTTP steps resolve workflow data before evaluating conditions; Framework steps use the shared workflow payload; tests cover names, IDs, evaluated values, and Liquid rendering.

Diagram

sequenceDiagram
    participant Job as HTTP step job
    participant Worker as ExecuteHttpRequestStep
    participant Repo as Workflow repository
    participant Helper as buildWorkflowVariables
    participant Rules as Skip rules
    participant HTTP as HTTP endpoint

    Job->>Worker: execute(command)
    alt command includes workflow
        Worker->>Worker: use command.workflow
    else command has _templateId
        Worker->>Repo: findById(_templateId, environmentId)
        Repo-->>Worker: workflow
    end
    Worker->>Helper: buildWorkflowVariables(workflow)
    Helper-->>Worker: workflowId, name, description, tags, severity
    Worker->>Rules: evaluate skip with workflow context
    alt condition says skip
        Rules-->>Worker: skip
        Worker-->>Job: SKIPPED
    else condition says run
        Rules-->>Worker: run
        Worker->>HTTP: send compiled request
        HTTP-->>Worker: response
        Worker-->>Job: result
    end
Loading

Reviews (3) · Last reviewed commit: "Refactor schema typing and JSON parsing"

…NV-8772

HTTP Request skip conditions and Liquid templates now receive the same
workflow namespace as channel steps, including workflow.workflowId mapped
from the trigger identifier.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
human-md Ready Ready Preview Sep 20, 2026 7:47am UTC

Request Review

@netlify

netlify Bot commented Sep 20, 2026

Copy link
Copy Markdown

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit 9dd79f7
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/6aaf8f9815c6550008735f90

@linear-code

linear-code Bot commented Sep 20, 2026

Copy link
Copy Markdown

NV-8772

Comment thread libs/application-generic/src/utils/build-workflow-variables.ts Outdated

@cursor cursor Bot 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.

🔒 Agentic Security Review — 1 finding (HIGH)

Reviewed PR #12675: fix(worker): expose workflow variables in HTTP step conditions fixes NV-8772
Author: @nikitagrossman

Summary: The fix is correct — HTTP request steps now get the workflow namespace. However, buildWorkflowVariables spreads the entire NotificationTemplateEntity into the Liquid compile context rather than allowlisting only the five fields the dashboard variable picker advertises. For the HTTP step path this is entirely new exposure, and the spread pulls in sensitive sub-documents including the updatedBy populated UserEntity (with no field projection in findById), which contains password (bcrypt hash), resetToken (live account-takeover token), and tokens (OAuth access/refresh tokens).

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment thread libs/application-generic/src/utils/build-workflow-variables.ts Outdated
Limit what buildWorkflowVariables exposes: add a typed IWorkflowForVariables, import SeverityLevelEnum, and return only advertised fields (workflowId, name, description, tags, severity) so internal persisted fields (ids, rawData, steps) are not leaked. Update tests to assert the exported keys and severity enum. Also reorder an export in utils index (integration-conditions moved) to keep exports consistent.
Add typed helpers and centralize control-schema handling across ConstructFrameworkWorkflow: introduce PersistedControlSchema, toFrameworkSchema, getStepTemplate and getControlSchema to remove repetitive unsafe casts and provide clearer errors for missing templates/controls. Update tests to use DeepPartial helpers and JsonSchemaTypeEnum for fixture schemas. Remove unnecessary casts for PERMISSIVE_EMPTY_SCHEMA and tighten types. In worker HTTP step, add HttpResponseBody type and type-safe tryParseJson, and add a lint ignore for cognitive complexity. These changes improve type safety and reduce repetitive casting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant