Skip to main content

Module compat

Module compat 

Source
Expand description

Compatibility with v3 definitions and behaviour.

Every v3 definition loads through the compat reader, which parse runs first when ParseOptions::compat is on (the default). It rewrites each v3 spelling into v4’s and reports the rewrite as a V3_SPELLING Advisory at the v3 key:

Wherev3 spellingv4 spelling
Workflowcontinue_on_error: true / falseon_failure: continue / fail
Taskcontinue_on_error: trueon_failure: continue, on_rejection: continue
Taskhalt_on: "failure"on_failure: fail, on_rejection: halt
Taskbothon_failure: halt, on_rejection: halt
Taskhalt_on: "never", continue_on_error: falsethe defaults, still reported
function.namevalidatevalidation

It moves two kinds of key into a node’s ext, reporting each as the key it is:

  • a key a built-in’s input does not know, which v3’s configs ignored, as function.input.<key>, and an unknown key of a map mapping or a validation rule, as function.input.mappings[0].<key> (an UNKNOWN_KEY, or a LIKELY_TYPO);
  • a group’s continue_on_error (a GROUP_CONTINUE_ON_ERROR when true, which v3 reported and never honoured, otherwise an UNKNOWN_KEY).

It refuses a continue_on_error that is not a bool and a halt_on that is not "never" or "failure". It refuses a v3 key written beside a v4 one, at the v3 key: on one node, any v3 policy key (continue_on_error, halt_on) beside any v4 policy key (on_failure, on_rejection).

With the reader off, nothing is rewritten. The v3 keys of a workflow, a task and a group (continue_on_error, halt_on) are unknown keys, and Rejected as every unknown key then is. validate and a built-in input’s stray keys are not keys of the definition: they stay in the task’s function as written, for the function’s lookup and config to refuse when the workflow is compiled.

migrate_v3 parses with the reader on and writes the definition in the v4 spelling, which parses with the reader off to an equal definition.

use dataflow_rs::compat::migrate_v3;
use serde_json::json;

let migrated = migrate_v3(&json!({
    "id": "w",
    "tasks": [{"id": "t", "continue_on_error": true, "function": {"name": "f", "input": {}}}]
}))
.unwrap();
assert_eq!(
    migrated.json,
    json!({"id": "w", "tasks": [{
        "id": "t", "on_failure": "continue", "function": {"name": "f", "input": {}}
    }]})
);
assert_eq!(migrated.rewrites[0].path.to_string(), "tasks[0].continue_on_error");
assert_eq!(
    migrated.rewrites[0].kind,
    dataflow_rs::compat::RewriteKind::Policy {
        v3: "continue_on_error: true".into(),
        v4: vec![
            ("on_failure".into(), "continue".into()),
            ("on_rejection".into(), "continue".into()),
        ],
    }
);
assert_eq!(
    migrated.rewrites[0].to_string(),
    "`continue_on_error: true` is a v3 spelling, read as `on_failure: continue, on_rejection: continue`"
);

Structs§

Migrated
A v3 definition in the v4 spelling: what migrate_v3 returns.
Rewrite
One v3 spelling the compat reader rewrote.

Enums§

RewriteKind
What a Rewrite changed: the v4 keys and values the reader wrote, so a host that migrates a stored definition applies them instead of parsing Display’s prose.

Functions§

migrate_v3
Parse with compat on and serialize the definition in the v4 spelling. Err holds every issue when any is Rejected; otherwise issues holds the rest.