K
Kinde2w ago
Dave

Can't find Workflows

Setting up a workflow. Have used an example and placed in environment/workflows in my repo per docs but am getting sync errors (not finding workflows). Have been trying different things including a kinde.json config file with rootDir = "environment/workflows". Filename of workflow ends in "...Workflow.ts". Am at a loss what to try due to limited ways to debug.
9 Replies
Ages - Kinde
Ages - Kinde2w ago
Hi Dave—sorry you’re running into this. To help troubleshoot, could you share a bit more detail: 1. Which workflow are you trying to sync? 2. A snippet of your repo structure around environment/workflows (so I can confirm the path and naming). 3. Your kinde.json (or framework config) showing the rootDir setting. 4. The exact error message or sync log you’re seeing when it fails to find the workflow. With those details (and even a copy/paste of the log), I can pinpoint what might be misaligned in the path, naming, or config. Thanks Hi Dave, In the meantime, these docs might be helpful: - About Workflows (triggers & use cases): https://docs.kinde.com/workflows/about-workflows - Create a Workflow: https://docs.kinde.com/workflows/manage-workflows/create-workflow - Connect Repo for Workflows: https://docs.kinde.com/workflows/about-workflows/connect-repo-for-workflows - Preview Workflows & Deployments: https://docs.kinde.com/workflows/manage-workflows/preview-workflows Feel free to dive into those sections for detailed examples and configuration options. Let me know if anything is unclear or if you have any questions—we're here to help
Dave
DaveOP2w ago
I've read all those sections of the docs multiple times. I don't know what I'm missing. I've created a new repo and added the bare minimum. I don't get an error and I unfortunately cannot see sync logs now from the prior repo, but I don't see any workflows after connecting to the repo and syncing. The Status page says workflows are ok. Here's my kinde.json:- { "rootDir":"environment/workflows" } Here's my environment/workflows/UserTokenWorklow.ts file:- import { accessTokenCustomClaims, onUserTokenGeneratedEvent, WorkflowSettings, WorkflowTrigger, } from "@kinde/infrastructure"; export const workflowSettings: WorkflowSettings = { id: "userTokenGeneration", name: "Access token custom claims", failurePolicy: { action: "stop", }, trigger: WorkflowTrigger.UserTokenGeneration, bindings: { "kinde.idToken": {}, // required to modify ID token claims "kinde.accessToken": {}, // required to modify access token claims url: {}, // required for url params }, }; export default async function handleUserTokens(event: onUserTokenGeneratedEvent) { const accessToken = accessTokenCustomClaims<{ companyName: string; }>(); accessToken.companyName = "Kinde"; };
Dave
DaveOP2w ago
I've attached a screenshot of my repo.
No description
Dave
DaveOP2w ago
GitHub
GitHub - davidcrouch/kinde_workflows
Contribute to davidcrouch/kinde_workflows development by creating an account on GitHub.
Ages - Kinde
Ages - Kinde2w ago
Hi Dave, It looks like Kinde isn’t discovering your workflow due to a couple of setup issues: 1. Incorrect rootDir in kinde.json
You currently have:
"rootDir": "environment/workflows"
This makes Kinde look for files in:
environment/workflows/environment/workflows/*.ts Fix: - Option A (recommended): - Move files to kindeSrc/environment/workflows/ - Set "rootDir": "kindeSrc" - Option B: - Keep files in environment/workflows/ - Set "rootDir": "" or "." 2. Filename typo
Your file is named UserTokenWorklow.ts. It must be UserTokenWorkflow.ts (case-sensitive and must end with Workflow.ts) 3. (Optional) Add "version": "2024-12-09" to kinde.json for stability and compatibility with newer features. 4. Sync your repo: - Push your changes - In Kinde: go to Settings &gt; Environment &gt; Git repo &gt; Sync code - Check sync logs for any errors 5. Once successful:
Go to Home &gt; Workflows and you should see the workflow (ID: userTokenGeneration) in Draft status Let me know if you run into anything else. Happy to help further
Dave
DaveOP2w ago
Thank you Ages. The filename was actually correct. I'd made a typo in my post. The issue was in the json config. I think the documentation should be revised to make it clear that rootDir is relative to environment/workflows. Thx. Dave.
Ages - Kinde
Ages - Kinde2w ago
Hi Dave, Thanks for the clarification. I’ve raised this internally, and I'm happy to share that our documentation team is already working on an update to clarify how rootDir behaves in relation to environment/workflows. Let me know if there’s anything else I can assist you with.
Dave
DaveOP2w ago
Thank you, Ages. Another question regarding workflow deploymet and execution. In my workflow I need to access the database of my application (the same one I'm protecting with Kinde) to get data to put into the access token. I've been looking into various design options such as sharing the library package that does the database lookup in the workflow, but to me that potentially opens a security issue since there's no security layer. One thought is to use an M2M API query to my app's API where I'm passing client credentials, and I'd use a scope to further restrict access. Now, the client credentials would be in a .env file. I was curious to understand how Kinde executes my workflow... if the .env will be read. What is the best practice for accessing proprietary back end data in the workflow?
Ages - Kinde
Ages - Kinde2d ago
Hi Dave, Thank you for your question! I’ll check internally and discuss this with our team to ensure we provide you with the best guidance on how to securely access proprietary backend data in your workflow, especially in relation to environment variables and M2M API queries. In the meantime, if you have any other questions or concerns, feel free to reach out. I’ll be happy to assist further Hi Dave

Regarding securely accessing your backend data and storing client credentials in workflows, our recommended best practice is to use Kinde’s Environment Variables feature to store sensitive information like your M2M client ID and secret outside of your source code
In your workflow file, enable the kinde.env binding so your code can access those variables at runtime without hard-coding them:
export const workflowSettings: WorkflowSettings = {
bindings: {
"kinde.env": {}
},
// ...other settings
};
export const workflowSettings: WorkflowSettings = {
bindings: {
"kinde.env": {}
},
// ...other settings
};
Then, within your workflow code, you can retrieve your credentials securely using the Kinde infrastructure helper:
import { getEnvironmentVariable } from "@kinde/infrastructure";

const clientId = getEnvironmentVariable("CLIENT_ID")?.value;
const clientSecret = getEnvironmentVariable("CLIENT_SECRET")?.value;
import { getEnvironmentVariable } from "@kinde/infrastructure";

const clientId = getEnvironmentVariable("CLIENT_ID")?.value;
const clientSecret = getEnvironmentVariable("CLIENT_SECRET")?.value;
Sensitive environment variables are redacted in logs and only accessible at runtime, ensuring they never appear in your Git history or output You can manage your variables (add, update non-sensitive values, or delete and recreate sensitive ones) via the Kinde dashboard under Settings &gt; Data management &gt; Env variables

For more details :
https://docs.kinde.com/workflows/configuration/environment-variables-and-secrets
https://docs.kinde.com/build/env-variables/add-manage-env-variables
https://docs.kinde.com/workflows/configuration/bindings Please let me know if you’d like a step-by-step walkthrough or have any other questions

Did you find this page helpful?