Skip to content

Conversation

@nailo2c
Copy link
Contributor

@nailo2c nailo2c commented Nov 9, 2025

Closes: #57355

When a user runs airflow config list --include-descriptions --include-examples,
multi-line values (like dag_bundle_config_list) would cause a
configparser.ParsingError due to improper indentation.

This fix pretty-prints the JSON value using json.dumps(indent=4)
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.

@potiuk
Copy link
Member

potiuk commented Nov 11, 2025

Why not fixing airflow config list --include-descriptions --include-examples to produce correct output ? I Think it makes very little sense to have working --defaults-no-comments flag when we can fix the original command.

@zachliu
Copy link
Contributor

zachliu commented Nov 12, 2025

the issue is caused by how python's configparser handles string-value fallback in their get method. when we use fallback=default_value, the indentations are removed. but when we use the set() and then get() without fallback, the indentations are intact 🤔

@zachliu
Copy link
Contributor

zachliu commented Nov 12, 2025

off the top of me head, i can change this line

value = self.get(section_to_write, option, fallback=default_value, raw=True)

into

    if isinstance(default_value, str):
        self.set(section_to_write, option, default_value)
        value = self.get(section_to_write, option, raw=True)
    else:
        value = self.get(section_to_write, option, fallback=default_value, raw=True)

@nailo2c
Copy link
Contributor Author

nailo2c commented Nov 16, 2025

Hi, I think potiuk is right. I fixed airflow config list --include-descriptions --include-examples, and now it produces the correct output. This approach is simpler than my original one. Please take a look and let me know if you have any feedback on the current version :)

root@7da61615e7c7:/opt/airflow# airflow config list --include-descriptions --include-examples | grep "dag_bundle_config_list" -A 10
# Example: dag_bundle_config_list = [
#       {
#         "name": "my-git-repo",
#         "classpath": "airflow.providers.git.bundles.git.GitDagBundle",
#         "kwargs": {
#           "subdir": "dags",
#           "tracking_ref": "main",
#           "refresh_interval": 0
#         }
#       }
#     ]
dag_bundle_config_list = [
        {
            "name": "dags-folder",
            "classpath": "airflow.dag_processing.bundles.local.LocalDagBundle",
            "kwargs": {}
        }
    ]

# How often (in seconds) to refresh, or look for new files, in a DAG bundle.
refresh_interval = 300

root@7da61615e7c7:/opt/airflow# 
root@7da61615e7c7:/opt/airflow# 
root@7da61615e7c7:/opt/airflow# python - <<'PY'
import configparser, pathlib, sys
p = configparser.ConfigParser()
p.read(pathlib.Path("airflow_new.cfg"))
PY
root@7da61615e7c7:/opt/airflow# 

@potiuk potiuk changed the title Add --defaults-no-comments option to airflow config list command Fixed config list ouput for multi-line values Nov 16, 2025
@potiuk
Copy link
Member

potiuk commented Nov 16, 2025

Looks good - I updated the title to reflect it, but it would also be great to edit description of the PR to not be misleading about the change (for posterity)

@potiuk
Copy link
Member

potiuk commented Nov 16, 2025

also rebasing and squashing into a single commit, properly described would be a good thing before we merge it.

Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
@nailo2c nailo2c force-pushed the bug-57355-fix-indent-for-dag_bundle_config_list-2 branch from d98aa41 to 8502bdc Compare November 16, 2025 17:30
@nailo2c
Copy link
Contributor Author

nailo2c commented Nov 16, 2025

Thanks for the review, rebasing and squashing are done 🙌

@potiuk potiuk added this to the Airflow 3.1.4 milestone Nov 16, 2025
@potiuk potiuk added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Nov 16, 2025
@potiuk potiuk merged commit d009b64 into apache:main Nov 16, 2025
64 checks passed
@potiuk
Copy link
Member

potiuk commented Nov 16, 2025

Thanks !

@github-actions
Copy link

Backport failed to create: v3-1-test. View the failure log Run details

Status Branch Result
v3-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker d009b64 v3-1-test

This should apply the commit to the v3-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

potiuk pushed a commit to potiuk/airflow that referenced this pull request Nov 16, 2025
Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
@potiuk
Copy link
Member

potiuk commented Nov 16, 2025

Backport in #58378

potiuk pushed a commit to potiuk/airflow that referenced this pull request Nov 16, 2025
Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
potiuk added a commit that referenced this pull request Nov 16, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 18, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 19, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 19, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
ephraimbuddy pushed a commit that referenced this pull request Nov 20, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
aaron-wolmutt pushed a commit to aaron-wolmutt/airflow that referenced this pull request Nov 20, 2025
Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
ephraimbuddy pushed a commit that referenced this pull request Dec 3, 2025
…8378)

Closes: #57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
(cherry picked from commit d009b64)

Co-authored-by: Aaron Chen <nailo2c@gmail.com>
Copilot AI pushed a commit to jason810496/airflow that referenced this pull request Dec 5, 2025
Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
itayweb pushed a commit to itayweb/airflow that referenced this pull request Dec 6, 2025
Closes: apache#57355

When a user runs `airflow config list --include-descriptions --include-examples`,
multi-line values (like `dag_bundle_config_list`) would cause a
`configparser.ParsingError` due to improper indentation.

This fix pretty-prints the JSON value using `json.dumps(indent=4)`
and then adds an additional four-space indent to each new line.
This ensures the INI parser treats the entire block as a
single, valid multi-line value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLI backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration parameter dag_bundle_config_list is generated without indentation

3 participants