Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-3514] [Feature] Use formatting for package-lock.yml that passes yamlint linting checks #9319

Closed
2 tasks done
nevdelap opened this issue Dec 28, 2023 · 3 comments · Fixed by #9341
Closed
2 tasks done
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!

Comments

@nevdelap
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

package-lock.yml does not have a document separator and does not have correct indentation.

Run ymllint --strict on a newly created package-lock.yml.

> dbt deps
> cat package-lock.yml
packages:
- package: dbt-labs/audit_helper
  version: 0.9.0
- package: dbt-labs/codegen
  version: 0.12.1
- package: dbt-labs/dbt_utils
  version: 1.1.1
sha1_hash: 3cf6af6c0a4ee17cf53205ae383d515915b55f5f
> docker run --rm -v $(pwd):/data cytopia/yamllint:latest --strict /data/package-lock.yml
/data/package-lock.yml
  1:1       warning  missing document start "---"  (document-start)
  2:1       error    wrong indentation: expected at least 1  (indentation)

> echo $?
1

Expected Behavior

That it be generated correctly formatted. For example here, when manually fixed it passes.

> cat package-lock.yml
---

packages:
  - package: dbt-labs/audit_helper
    version: 0.9.0
  - package: dbt-labs/codegen
    version: 0.12.1
  - package: dbt-labs/dbt_utils
    version: 1.1.1
sha1_hash: 3cf6af6c0a4ee17cf53205ae383d515915b55f5f
> docker run --rm -v $(pwd):/data cytopia/yamllint:latest --strict /data/package-lock.yml
> echo $?
0

Steps To Reproduce

As above.

Relevant log output

N/A

Environment

- OS: Linux
- Python: 3.11
- dbt: 1.7.4

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@nevdelap nevdelap added bug Something isn't working triage labels Dec 28, 2023
@github-actions github-actions bot changed the title package-lock.yml doesn't pass yamlint, causing difficulties and manual formatting for CI. [CT-3514] package-lock.yml doesn't pass yamlint, causing difficulties and manual formatting for CI. Dec 28, 2023
@dbeatty10 dbeatty10 self-assigned this Jan 2, 2024
@dbeatty10
Copy link
Contributor

Thanks for noticing this and reaching out about it with a nice write-up @nevdelap ! 🤩

This seems to only affect linting rather than the actual behavior of dbt, so I'm going to re-categorize this as a feature request.

I don't see a need for us to add the --- part since we haven't typically included it in our style guide for other YAML documents like dbt_project.yml, etc. Do you see value in us adding the document start for package-lock.yml?

The workaround we'd recommend is to use the various configuration options for yamllint to either ignore package-lock.yml entirely or to relax the strictness.

In the meantime, I'm going to label it as a good_first_issue for a community member to tackle the indentation portion.

Acceptance criteria

  • after running dbt deps, package-lock.yml contains an indention level of 2 spaces and looks similar to below

  • yamllint --strict package-lock.yml --no-warnings has an exit code of 0

    • use echo $? to see the exit code

    package-lock.yml

    packages:
      - package: dbt-labs/audit_helper
        version: 0.9.0
    sha1_hash: 3cf6af6c0a4ee17cf53205ae383d515915b55f5f

@dbeatty10 dbeatty10 added enhancement New feature or request and removed bug Something isn't working triage labels Jan 2, 2024
@dbeatty10 dbeatty10 changed the title [CT-3514] package-lock.yml doesn't pass yamlint, causing difficulties and manual formatting for CI. [CT-3514] [Feature] Use formatting for package-lock.yml that passes yamlint linting checks Jan 2, 2024
@dbeatty10 dbeatty10 removed their assignment Jan 2, 2024
@dbeatty10 dbeatty10 added the good_first_issue Straightforward + self-contained changes, good for new contributors! label Jan 2, 2024
@jx2lee
Copy link
Contributor

jx2lee commented Jan 5, 2024

can i take this issue?

@dbeatty10
Copy link
Contributor

can i take this issue?

Yup, sounds great @jx2lee 👍 Thanks for opening #9341 🏆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants