OpenFn / OpenFn/lightning

Demo credentials are created with no body, so demo runs fail before the job starts

Open
#5,164 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

The demo data creates a credential with no body, so the first time anyone runs one of the demo workflows it fails before the job starts.

The run ends as an exception with this, which reads like the operator forgot to configure something:

CredentialLoadError: Failed to load credential ...: [fetch:credential] Credential environment mismatch.
This project is using 'unknown' but credential 'DHIS2 play' does not have a matching environment.

There is nothing to configure. The credential genuinely has no body at all. select count(*) from credential_bodies comes back zero on a freshly seeded database, while the credential row itself exists.

The cause is that credential bodies moved into their own table with an environment name, and the demo still passes the old shape. Credentials.create_credential builds bodies only from a credential_bodies key, and the demo hands it body, which is dropped on the floor without complaint.

lib/lightning/setup_utils.ex does not mention credential_bodies anywhere, so both of its credential paths are affected: the DHIS2 credential it builds itself, and any credential passed through setup_user.

Worth fixing in two places. The demo should pass a body in the shape the new schema expects, with an environment that matches the project it belongs to. And creating a credential with a body the function ignores should not succeed silently, because that is what turned a seeding bug into a runtime error message pointing the reader at a settings page that cannot help them.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start in lib/lightning/setup_utils.ex and inspect both credential paths, then trace how Credentials.create_credential consumes credential_bodies. Update the demo body shape and matching environment, and ensure an ignored body cannot succeed silently; verify a freshly seeded database contains credential_bodies and the demo workflow starts successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.