Skip to content

yq with TOML in GitHub Actions results in mangled output #2710

@tmercswims

Description

@tmercswims

Describe the bug
I'm using the yq GitHub Actions action to set a project version in a pyproject.toml. When I do this, the resulting file is missing a large chunk, the rest is rearranged, and it results in failures down the line.

Version of yq: GitHub Action @4
Operating system: ubuntu-latest on GitHub Actions runner
Installed via: GitHub Action

Input TOML
pyproject.toml:

[tool.poetry]
name = "my-project"
version = "0.0.0.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
fastapi = "^0.115.0"
uvicorn = "^0.30.6"
python-dotenv = "^1.0.1"
pydantic-settings = "^2.5.2"
python-json-logger = "^2.0.7"
httpx = "^0.27.2"
langchain = "^0.3.0"
langchain-openai = "^0.2.0"
langchain-community = "^0.3.0"
itsdangerous = "^2.2.0"
SQLAlchemy = "^2.0.35"
PyMySQL = "^1.1.1"
pytest-sqlalchemy = "^0.2.1"
cryptography = "^44.0.1"
alembic = "^1.13.3"
redis = "^5.1.0"
langchain-redis = "^0.1.0"
motor = "^3.6.0"
langchain-mongodb = "^0.2.0"
importlib-metadata = "8.4.0"
ddtrace = "^2.14.4"
toml = "^0.10.2"
aiomysql = "^0.2.0"
aiosqlite = "^0.20.0"
aiohttp = ">=3.11.0,<3.11.13"
aiokafka = "^0.12.0"
confluent-kafka = "^2.6.0"
astroid = "^3.3.6"
atlassian-python-api = "^3.41.16"
langfuse = "^2.56.1"
pyinstrument = "^5.0.0"
deepeval = "^2.1.1"
pyjwt = "^2.10.1"
jsonschema = "^4.17.3"
openapi-schema-validator = "^0.4.1"
pytest-celery = "^1.2.0"
langdetect = "^1.0.9"
celery = { extras = ["asyncio"], version = "^5.4.0" }
pydantic = { extras = ["email"], version = "^2.10.1" }

[tool.poetry.group.dev.dependencies]
black = "^24.10.0"
pylint = "^3.3.1"
ruff = "^0.6.8"
flake8 = "^7.1.1"
flake8-spellcheck = "^0.28.0"
pre-commit = "^4.0.1"
codespell = "^2.2.5"
pytest-asyncio = "^0.24.0"
aiomysql = "^0.2.0"
pytest = "^8.3.3"
pytest-cov = "^6.0.0"
coverage-badge = "^1.1.2"
sqlalchemy = { extras = ["asyncio"], version = "^2.0.36" }

[tool.black]
line-length = 88

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Command
The command you ran:

- name: Update version in pyproject.toml
  uses: mikefarah/yq@v4
  with:
    cmd: |
      yq -i '.tool.poetry.version = "${{ github.ref_name }}"' pyproject.toml

Actual behaviour

[tool.poetry]
name = "apim-bot-server"
version = "12.6.0.10"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
group = { dev = { dependencies = { black = "^24.10.0", pylint = "^3.3.1", ruff = "^0.6.8", flake8 = "^7.1.1", flake8-spellcheck = "^0.28.0", pre-commit = "^4.0.1", codespell = "^2.2.5", pytest-asyncio = "^0.24.0", aiomysql = "^0.2.0", pytest = "^8.3.3", pytest-cov = "^6.0.0", coverage-badge = "^1.1.2", sqlalchemy = { extras = ["asyncio"], version = "^2.0.36" } } } }

[tool.black]
line-length = 88

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

The sections have been collapsed, and the [tool.poetry.dependencies] section is completely gone.

Expected behaviour

[tool.poetry]
name = "my-project"
version = "12.6.0.11"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
fastapi = "^0.115.0"
uvicorn = "^0.30.6"
python-dotenv = "^1.0.1"
pydantic-settings = "^2.5.2"
python-json-logger = "^2.0.7"
httpx = "^0.27.2"
langchain = "^0.3.0"
langchain-openai = "^0.2.0"
langchain-community = "^0.3.0"
itsdangerous = "^2.2.0"
SQLAlchemy = "^2.0.35"
PyMySQL = "^1.1.1"
pytest-sqlalchemy = "^0.2.1"
cryptography = "^44.0.1"
alembic = "^1.13.3"
redis = "^5.1.0"
langchain-redis = "^0.1.0"
motor = "^3.6.0"
langchain-mongodb = "^0.2.0"
importlib-metadata = "8.4.0"
ddtrace = "^2.14.4"
toml = "^0.10.2"
aiomysql = "^0.2.0"
aiosqlite = "^0.20.0"
aiohttp = ">=3.11.0,<3.11.13"
aiokafka = "^0.12.0"
confluent-kafka = "^2.6.0"
astroid = "^3.3.6"
atlassian-python-api = "^3.41.16"
langfuse = "^2.56.1"
pyinstrument = "^5.0.0"
deepeval = "^2.1.1"
pyjwt = "^2.10.1"
jsonschema = "^4.17.3"
openapi-schema-validator = "^0.4.1"
pytest-celery = "^1.2.0"
langdetect = "^1.0.9"
celery = { extras = ["asyncio"], version = "^5.4.0" }
pydantic = { extras = ["email"], version = "^2.10.1" }

[tool.poetry.group.dev.dependencies]
black = "^24.10.0"
pylint = "^3.3.1"
ruff = "^0.6.8"
flake8 = "^7.1.1"
flake8-spellcheck = "^0.28.0"
pre-commit = "^4.0.1"
codespell = "^2.2.5"
pytest-asyncio = "^0.24.0"
aiomysql = "^0.2.0"
pytest = "^8.3.3"
pytest-cov = "^6.0.0"
coverage-badge = "^1.1.2"
sqlalchemy = { extras = ["asyncio"], version = "^2.0.36" }

[tool.black]
line-length = 88

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Additional context
Bizarrely, this exact thing works as expected when I run it on my local machine with yq 4.53.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions