Skip to content

feat: new deploy diff#1352

Merged
josephjclark merged 19 commits intomainfrom
diff-stuff
Apr 16, 2026
Merged

feat: new deploy diff#1352
josephjclark merged 19 commits intomainfrom
diff-stuff

Conversation

@doc-han
Copy link
Copy Markdown
Collaborator

@doc-han doc-han commented Apr 2, 2026

Short Description

Add a rich diff and JSON diff readout to openfn project deploy

Fixes #1182

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

@github-project-automation github-project-automation bot moved this to New Issues in Core Apr 2, 2026
@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 2, 2026

Issue I'm dealing with while doing manual testing. cc: @josephjclark
trying to get this resolved at the moment

Screenshot 2026-04-02 at 7 48 50 AM

@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 2, 2026

Issue I'm dealing with while doing manual testing. cc: @josephjclark trying to get this resolved at the moment

The fix for this bug I was facing was sitting all the base in https://github.com/OpenFn/kit/blob/main/packages/project/src/util/base-merge.ts
The call to assign over there was mutating the value of target in-place making it lose the methods on workflows.

@doc-han doc-han marked this pull request as ready for review April 7, 2026 10:45
@doc-han doc-han requested a review from josephjclark April 7, 2026 10:51
@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: changing the id of a step results in this error:

[CLI] ✘ TypeError: Cannot read properties of undefined (reading 'name')
    at file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:279:57
    at Array.map (<anonymous>)
    at generateHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:276:46)
    at Workflow.getVersionHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:462:12)
    at findLocallyChangedWorkflows (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2277:35)
    at syncProjects (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2412:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async handler (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2507:24)
    at async parse (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:4126:12)

@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: removing the configuration key doesn't seem to generate a diff (in the rich or the json one). But it should result in a change in the state.json right? I wonder if that's a wider bug

@josephjclark
Copy link
Copy Markdown
Collaborator

Issue: changes to edges don't seem to manifest in the rich diff (I do see them in JSON)

Copy link
Copy Markdown
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really cool!

I've tested around a bit and found some issues. But before we go too much further I'm not sure the architecture is right, and I'd like to dig into that a bit with you later

Comment thread packages/cli/src/projects/deploy.ts Outdated
Comment thread packages/cli/src/projects/deploy.ts Outdated
Comment thread packages/cli/src/projects/deploy.ts Outdated
Comment thread packages/cli/src/projects/deploy.ts Outdated
Comment thread packages/cli/src/projects/deploy.ts
Comment thread packages/cli/src/projects/deploy.ts Outdated
Comment thread packages/cli/src/projects/deploy.ts Outdated
@github-project-automation github-project-automation bot moved this from New Issues to In review in Core Apr 7, 2026
@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 13, 2026

Suggestion: When a user hits divergence because the project on remote changed but the locally pulled project has zero changes since last pulled. openfn project pull should automatically do a --force pull. The user shouldn't have to explicitly pass --force
cc: @josephjclark

@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 13, 2026

Issue: changing the id of a step results in this error:

[CLI] ✘ TypeError: Cannot read properties of undefined (reading 'name')
    at file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:279:57
    at Array.map (<anonymous>)
    at generateHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:276:46)
    at Workflow.getVersionHash (file:///home/joe/repo/openfn/kit/packages/project/dist/index.js:462:12)
    at findLocallyChangedWorkflows (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2277:35)
    at syncProjects (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2412:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async handler (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:2507:24)
    at async parse (file:///home/joe/repo/openfn/kit/packages/cli/dist/process/runner.js:4126:12)

This has been resolved. It happens when you change the id of a job but then didn't do same for all edges referencing it. The error has been updated to print out a bit more meaningful message.

@doc-han doc-han requested a review from josephjclark April 13, 2026 08:12
@doc-han
Copy link
Copy Markdown
Collaborator Author

doc-han commented Apr 13, 2026

I've done several manual testing on this and it works fine.
This morning I added a change which shows what changes for an edge.

@josephjclark
Copy link
Copy Markdown
Collaborator

This is looking absolutely lovely

image

Will be testing closely and might jump in a with a fix. Aiming to get this released today.

@josephjclark
Copy link
Copy Markdown
Collaborator

Struggling with the review because I'm hitting type issues. I've raised out #1381

I think I'll continue to test and validate this and then still aim to get this PR released today, even if it has type issues

): StepChange[] => {
if (!localWf || !remoteWf) return [];

const localSteps = localWf.steps as any[];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Struggling here with:
a) the typing as any - this tells me that types are broken and I need to go off and fix that
b) we're not using provisioner state to do our diffing here- that was a core tenant of the issue

Now I'm going to relax on the provisioner state thing. The problem there is that in provisioner state we call it a body. but in your workflow.yam it's called expression. We have to relate the diff back in local terms.

It just opens up a gap between what we report on for the diff, and what diff factually materialises when we post to the server. Makes me nervous.

The JSON diff resolves this by doing a pure diff on the two JSON structures... but it'll report the diff with keys that may not be familiar. And of course the JSON diff might not necessarily be the same as the database diff (like you can add a key to the JSON that the provisioner will ignore, so it's not really a diff)

};
};

const TRACKED_FIELDS: Array<{ key: 'name' | 'adaptor' }> = [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me a little nervous. Why not just diff on all keys? If we add a new key tomorrow then we'll have to patch the CLI to report a diff on it.

I get that we have special handling for some keys, like expression, but I sort of thing we should have a fallback of just reporting anything.

@josephjclark
Copy link
Copy Markdown
Collaborator

Ok here's what I've done:

  • I've added support for diffing configuration (not that this seems terribly useful)
  • I've made the diff reporter in the CLI a bit more generalised
  • I've generated a bunch of unit tests against diff-workflow with Claude
  • I've raised an issue to reorganise typings properly

I think we're good to launch

@josephjclark josephjclark merged commit a3aa3d9 into main Apr 16, 2026
7 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Core Apr 16, 2026
@josephjclark josephjclark deleted the diff-stuff branch April 16, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

new deploy diff

3 participants