Skip to content

Conversation

@guillaumededrie
Copy link
Contributor

Changes

This add support for cases where templates are used as key in Yaml files.

Context

See: #18470 (reply in thread)

For example, when having a docker-compose.yaml.j2 file like the following:

---
# {{ ansible_managed }}
version: "3.8"

networks:
  {{ network_name }}:
    external: true

services:
  app:
    image: "<NAME>@<HASH>"
    networks:
      - {{ network_name }}
    command: command
    deploy:
      mode: global
      placement:
        {{ placement | ansible.builtin.to_nice_yaml | indent(10) }}
      labels:
        - "name=value"

Renovate was failing with the following error:

DEBUG: docker-compose.extractPackageFile(<REDACTED>/docker-compose.yml.j2)
DEBUG: Parsing Docker Compose config YAML failed
{
  "err": {
    "message": "Schema error",
    "stack": "ZodError: Schema error\n    at Object.get error [as error] (/usr/local/renovate/node_modules/.pnpm/zod@3.24.1/node_modules/zod/lib/types.js:55:31)\n    at ZodUnion.parse (/usr/local/renovate/node_modules/.pnpm/zod@3.24.1/node_modules/zod/lib/types.js:131:22)\n    at parseSingleYaml (/usr/local/renovate/lib/util/yaml.ts:136:17)\n    at Object.extractPackageFile (/usr/local/renovate/lib/modules/manager/docker-compose/extract.ts:39:29)\n    at extractPackageFile (/usr/local/renovate/lib/modules/manager/index.ts:75:9)\n    at getManagerPackageFiles (/usr/local/renovate/lib/workers/repository/extract/manager-files.ts:58:43)\n    at /usr/local/renovate/lib/workers/repository/extract/index.ts:57:28\n    at async Promise.all (index 1)\n    at extractAllDependencies (/usr/local/renovate/lib/workers/repository/extract/index.ts:54:26)\n    at extract (/usr/local/renovate/lib/workers/repository/process/extract-update.ts:159:28)\n    at extractDependencies (/usr/local/renovate/lib/workers/repository/process/index.ts:158:26)\n    at Object.renovateRepository (/usr/local/renovate/lib/workers/repository/index.ts:71:9)\n    at attributes.repository (/usr/local/renovate/lib/workers/global/index.ts:206:11)\n    at start (/usr/local/renovate/lib/workers/global/index.ts:191:7)\n    at /usr/local/renovate/lib/renovate.ts:19:22",
    "issues": [
      "Expected object, received null",
      "Expected object, received null"
    ]
  }
  "packageFile": "<REDACTED>/docker-compose.yml.j2"
}

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@guillaumededrie
Copy link
Contributor Author

I see a lot of side effect especially for Helm charts here…

I have no problems to invest more time, but maybe it would be better to discuss if the way I'm doing it here is acceptable first.

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

failing tests

}

function getShortHash(data: any): string {
return crypto.createHash('sha256').update(data).digest('hex').substring(0, 7);
Copy link
Member

Choose a reason for hiding this comment

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

we've a hash util function, please use that

@@ -0,0 +1,26 @@
---
Copy link
Member

Choose a reason for hiding this comment

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

reduce to minimum and inline

@secustor
Copy link
Member

secustor commented Jan 2, 2025

Please open a separate discussions regarding this scenario so we can discuss the solution.
E.g. IMO the YAML parser should be configured to allow null objects.

You can tag me there.

@secustor secustor marked this pull request as draft January 2, 2025 10:12
@rarkins rarkins added the auto:close-inactive-pr Inactive PR should be closed label Apr 27, 2025
@github-actions
Copy link
Contributor

Hi there,

We're closing this PR due to inactivity, but we are happy for you, or others, to finish the PR if time allows.

Thanks, the Renovate team

@github-actions github-actions bot closed this Apr 27, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

auto:close-inactive-pr Inactive PR should be closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants