python-jsonschema / python-jsonschema/check-jsonschema

Gitlab ci `!reference` in cache is not validating correctly anymore

Open
#498 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

gitlab-reference-support
Dominant language
Python
Stars
341
Forks
71
Avg merge
15d 20h
Merged PRs (30d)
4

Description

Since the new update , for this code:

  cache:
    - paths:
        - ${PIP_CACHE_DIR}
      key:
        prefix: "pip-${PYTHON_VERSION}-${CI_JOB_NAME}-${TOX_VERSION}"
        files:
          - requirements.txt
    - !reference [ .apt:cache, cache ]

I'm getting this error:

  .gitlab-ci.yml::$.test.cache: [{'paths': ['${PIP_CACHE_DIR}'], 'key': {'prefix': 'pip-${PYTHON_VERSION}-${CI_JOB_NAME}-${TOX_VERSION}', 'files': ['requirements.txt']}}, ['.apt:cache', 'cache']] is not valid under any of the given schemas
  Underlying errors caused this.

  Best Match:
    $.test.cache: [{'paths': ['${PIP_CACHE_DIR}'], 'key': {'prefix': 'pip-${PYTHON_VERSION}-${CI_JOB_NAME}-${TOX_VERSION}', 'files': ['requirements.txt']}}, ['.apt:cache', 'cache']] is not of type 'object'
  Best Deep Match:
    $.test.cache[1]: ['.apt:cache', 'cache'] is not of type 'object'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the validation error with the GitLab CI YAML shown in the issue, then trace the GitLab CI schema validation path. Done means the cache entry using !reference [ .apt:cache, cache ] is accepted correctly and the regression is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, yaml
Domain
ci-cd, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.