Skip to content

Airflow 3.0.0 : Import Variables from GUI fails with "Error Parsing JSON File" #49837

Closed

Description

@gbonazzoli

Apache Airflow version

3.0.0

If "Other Airflow 2 version" selected, which one?

No response

What happened?

Airflow 3.0.0 : Import Variables from GUI fails with "Error Parsing JSON File",

Image

but the same JSON file is correctly imported from the CLI:

(venv) root@airflow-tre:~/airflow# airflow variables import variables.json 
5 of 5 variables successfully updated.

What you think should happen instead?

The correct behaviour is to import variables.

How to reproduce

Export variables from an airflow 2.x instance and try to import them on Airflow 3.0.0

Operating System

Ubuntu 24.04.2 LTS

Versions of Apache Airflow Providers

apache-airflow-providers-celery==3.10.6
apache-airflow-providers-common-compat==1.6.0
apache-airflow-providers-common-io==1.5.4
apache-airflow-providers-common-sql==1.26.0
apache-airflow-providers-git==0.0.2
apache-airflow-providers-postgres==6.1.3
apache-airflow-providers-redis==4.0.2
apache-airflow-providers-smtp==2.0.3
apache-airflow-providers-ssh==4.0.1
apache-airflow-providers-standard==1.0.0

Deployment

Virtualenv installation

Deployment details

Nothing special, vanilla LXD Ubuntu 24.04 container and vanilla Airflow installation.

Anything else?

no

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:bug
    needs-triage
    on Apr 27, 2025
  2. added
    area:UI
    on Apr 27, 2025
  3. tirkarthi commented on Apr 27, 2025

    @tirkarthi
    Contributor

    value of the variable is expected to be a string which is not the case with json.loads used in cli that doesn't perform this validation. Variable values other than string and conforming to the JSON spec like int, list, dict etc should be allowed like the cli implementation.

    const text = event.target?.result as string;
    const parsedContent = JSON.parse(text) as unknown;
    if (
    typeof parsedContent === "object" &&
    parsedContent !== null &&
    Object.entries(parsedContent).every(
    ([key, value]) => typeof key === "string" && typeof value === "string",
    )
    ) {
    const typedContent = parsedContent as Record<string, string>;
    setFileContent(typedContent);
    } else {
    throw new Error("Invalid JSON format");

    cc: @shubhamraj-git

  4. added
    affected_version:3.0
    priority:medium
    and removed
    needs-triage
    on Apr 28, 2025
  5. added this to the Airflow 3.0.1 milestone on Apr 28, 2025
  6. ldacey commented on May 6, 2025

    @ldacey
    Contributor

    Ran into this as well. Ultimately I just added the key and pasted the value and did not use the import feature. The file format is the same as it always was during Airflow 2 though, it is a Variable I update manually once per month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

affected_version:3.0area:UIarea:corekind:bugpriority:medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions