fix(automations): pass companyId into resolveExecutableActionNodes to scope round-robin user assignment

Open Beginner friendly
#43 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, typescript
Domain
backend, databases

Research direction

Start in apps/api/src/instagram/services/instagram-automation-runner.service.ts and read the three named call sites plus resolveExecutableActionNodes. Trace how each call obtains the Instagram account’s company ID, then check how round-robin assignment handles a missing ID. Done means all three calls pass the company ID and assignment cannot query users across companies; the payload names no test file.

Written by the indexing model from the issue text.

Description

backend bug
Problem Description

In apps/api/src/instagram/services/instagram-automation-runner.service.ts (resolveExecutableActionNodes, lines 1027-1035), ACTION_SET_VARIABLE round-robin user assignment checks:
context.companyId ? { companyId: context.companyId } : { companyId: { not: null } }

However, companyId is never passed in context at any of the 3 call sites (resumeWaitingExecution line 379, triggerMatchingAutomations line 748, executeAutomationBranchPath line 1728). As a result, context.companyId is always undefined, causing round-robin assignment to query users across all companies instead of only the current workspace.


Expected Behavior
  1. companyId must always be passed into resolveExecutableActionNodes from all runner call sites.
  2. Round-robin assignment must fail closed (skip/error) if context.companyId is missing, rather than falling back to { companyId: { not: null } }.

Where to Look
  • apps/api/src/instagram/services/instagram-automation-runner.service.ts (resumeWaitingExecution, triggerMatchingAutomations, executeAutomationBranchPath, resolveExecutableActionNodes)

Solution / Implementation Guide
  1. Pass companyId: instagramAccount.companyId in the context object at resumeWaitingExecution (L379), triggerMatchingAutomations (L748), and executeAutomationBranchPath (L1728).
  2. Inside resolveExecutableActionNodes (L1027-1035), remove the { companyId: { not: null } } fallback and require context.companyId (or resolve assignToUserIds scoped strictly to { companyId: context.companyId }).
Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
6m
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sumamakhan761/tryinstance

All issues in sumamakhan761/tryinstance

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.