Skip to content

fix(sh): fallback to sh printer when dockerfmt throws #455

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

Merged
merged 2 commits into from
May 9, 2025
Merged

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented May 9, 2025

close #441

close #445


Important

Add fallback to sh printer in dockerPrinter when dockerfmt throws, with new test case for verification.

  • Behavior:
    • In dockerPrinter.print() in index.ts, add fallback to sh printer when dockerfmt throws an error.
    • Handles unexpected errors from dockerfmt by using sh printer with the same options.
  • Testing:
    • Add test case for 445.Dockerfile in fixtures.spec.ts.snap to verify fallback behavior.
    • New fixture 445.Dockerfile added for testing in test/fixtures.
  • Misc:
    • Update ShPrintOptions in index.ts to include additional printer options.

This description was created by Ellipsis for 1ea6700. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for Dockerfile formatting to ensure formatting continues even if the Dockerfile formatter encounters issues, by automatically falling back to an alternative formatter.
  • Tests

    • Added a new Dockerfile test case to verify formatting and fallback behavior.

@JounQin JounQin requested a review from Copilot May 9, 2025 11:07
@JounQin JounQin self-assigned this May 9, 2025
@JounQin JounQin added bug Something isn't working upstream workaround labels May 9, 2025
Copy link

changeset-bot bot commented May 9, 2025

🦋 Changeset detected

Latest commit: 215adba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
prettier-plugin-sh Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 85.10%. Comparing base (7b4f0f0) to head (215adba).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/sh/src/index.ts 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #455      +/-   ##
==========================================
- Coverage   85.71%   85.10%   -0.61%     
==========================================
  Files          10       10              
  Lines         182      188       +6     
  Branches       47       51       +4     
==========================================
+ Hits          156      160       +4     
- Misses         25       27       +2     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

coderabbitai bot commented May 9, 2025

Walkthrough

This change introduces a fallback mechanism in the prettier-plugin-sh package's Dockerfile printer. If the dockerfmt printer encounters an error, formatting now falls back to the sh printer with full option support. A new test fixture Dockerfile and a changeset documenting the patch are also added.

Changes

File(s) Change Summary
packages/sh/src/index.ts Expanded the dockerPrinter.print function signature to accept more options, wrapped the dockerfmt call in a try-catch, and implemented fallback to the sh printer with robust error handling and option passthrough.
packages/sh/test/fixtures/445.Dockerfile Added a new Dockerfile fixture for testing, featuring build arguments, file copies, and command execution for nginx.
.changeset/rotten-dancers-bow.md Added a changeset documenting the patch, describing the fallback mechanism for the Dockerfile printer.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Prettier
    participant dockerPrinter
    participant dockerfmt
    participant shPrinter

    User->>Prettier: Format Dockerfile
    Prettier->>dockerPrinter: print(path, options)
    dockerPrinter->>dockerfmt: formatDockerfileContents(path, options)
    alt dockerfmt succeeds
        dockerfmt-->>dockerPrinter: formatted content
        dockerPrinter-->>Prettier: formatted content
    else dockerfmt throws error
        dockerPrinter->>shPrinter: print(path, options)
        shPrinter-->>dockerPrinter: formatted content
        dockerPrinter-->>Prettier: formatted content
    end
    Prettier-->>User: Output formatted Dockerfile
Loading

Assessment against linked issues

Objective Addressed Explanation
Fallback to sh printer when dockerfmt fails to prevent formatting errors (#441)
Ensure fallback passes all relevant options and maintains formatting integrity (#441, #445)
No evidence of changes related to markdown bash script deletion issue (#445) The changes focus on Dockerfile formatting; no direct fix for markdown bash code block deletion.

Possibly related PRs

Poem

A Dockerfile danced, then tripped on a bug,
But the rabbit was ready with a fallback hug.
If dockerfmt stumbles, the sh printer hops in,
Ensuring your scripts always finish with a grin.
With robust new options and a safety net in tow,
The formatter’s journey continues to flow! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/sh/src/index.ts

Oops! Something went wrong! :(

ESLint: 9.26.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b4f0f0 and 215adba.

⛔ Files ignored due to path filters (1)
  • packages/sh/test/__snapshots__/fixtures.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • .changeset/rotten-dancers-bow.md (1 hunks)
  • packages/sh/src/index.ts (1 hunks)
  • packages/sh/test/fixtures/445.Dockerfile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
🔇 Additional comments (6)
.changeset/rotten-dancers-bow.md (1)

1-6: Changeset properly documents the fallback mechanism

The changeset correctly identifies this as a patch for the prettier-plugin-sh package and clearly describes the fallback mechanism being implemented.

packages/sh/test/fixtures/445.Dockerfile (1)

1-7: Test fixture looks good and follows Docker best practices

This test fixture serves as an appropriate test case for the fallback mechanism, with the filename matching issue #445 referenced in the PR objectives. The Dockerfile follows best practices:

  • Uses official nginx image
  • Sets working directory
  • Uses ARGs for configurability
  • Follows a clean copy and configuration pattern
  • Uses a proper CMD with prerequisite check
packages/sh/src/index.ts (4)

116-136: Good enhancement of the printer options

The dockerPrinter.print method has been expanded to accept additional parser and printer options, aligning it with the sh printer's capabilities. This provides better consistency between both printers.


127-127: Default indentation logic is improved

The updated indentation logic correctly handles the case when tabs are not used by falling back to tabWidth ?? 2.


139-171: Good implementation of the fallback mechanism

The try-catch implementation provides a robust fallback mechanism when dockerfmt throws an error, addressing the issues mentioned in the PR objectives.


153-170: Good implementation of processor parameters

The fallback mechanism correctly passes all the necessary parameters to the sh processor, ensuring that all formatting options are properly handled.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codesandbox-ci bot commented May 9, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses issues with dockerfmt by introducing a fallback to the sh printer when formatting a Dockerfile fails. The key changes include adding a new Dockerfile fixture (445.Dockerfile), updating corresponding snapshots, and wrapping the dockerfmt call in a try-catch to enable fallback printing with adjusted options.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/sh/test/fixtures/445.Dockerfile New Dockerfile fixture added for testing purposes.
packages/sh/test/snapshots/fixtures.spec.ts.snap Updated snapshots to reflect the changes in formatting Dockerfile output.
packages/sh/src/index.ts Implemented try-catch in the dockerPrinter and introduced fallback logic.

@JounQin JounQin changed the title fix: fallback to sh printer when dockerfmt throws fix: fallback to sh printer when dockerfmt throws May 9, 2025
Copy link

pkg-pr-new bot commented May 9, 2025

Open in StackBlitz

prettier-plugin-autocorrect

npm i https://pkg.pr.new/prettier-plugin-autocorrect@455

prettier-plugin-pkg

npm i https://pkg.pr.new/prettier-plugin-pkg@455

prettier-plugin-sh

npm i https://pkg.pr.new/prettier-plugin-sh@455

prettier-plugin-sql

npm i https://pkg.pr.new/prettier-plugin-sql@455

prettier-plugin-toml

npm i https://pkg.pr.new/prettier-plugin-toml@455

commit: 215adba

Copy link

sonarqubecloud bot commented May 9, 2025

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Contributor

github-actions bot commented May 9, 2025

size-limit report 📦

Path Size
packages/autocorrect/lib/index.js 538 B (0%)
packages/pkg/lib/index.js 447 B (0%)
packages/sh/lib/index.js 3.24 KB (+2.92% 🔺)
packages/sql/lib/index.js 2.4 KB (0%)

Copy link
Contributor

github-actions bot commented May 9, 2025

Deploy preview for prettier ready!

✅ Preview
https://prettier-i14prh4ps-1stg.vercel.app

Built with commit 215adba.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

github-actions bot commented May 9, 2025

📊 Package size report   0.05%↑

File Before After
.changeset/rotten-dancers-bow.md 91 B
packages/sh/src/index.ts 12.2 kB 9%↑13.3 kB
packages/sh/test/__snapshots__/fixtures.spec.ts.snap 28.9 kB 1%↑29.2 kB
packages/sh/test/fixtures/445.Dockerfile 198 B
Total (Includes all files) 3.3 MB 0.05%↑3.3 MB
Tarball size 1.2 MB 0.04%↑1.2 MB
Unchanged files
File Size
.changeset/config.json 313 B
.changeset/README.md 510 B
.codesandbox/ci.json 38 B
.editorconfig 161 B
.gitattributes 152 B
.github/workflows/autofix.yml 924 B
.github/workflows/ci.yml 1.6 kB
.github/workflows/pkg-pr-new.yml 690 B
.github/workflows/pkg-size.yml 601 B
.github/workflows/release.yml 1.3 kB
.github/workflows/size-limit.yml 794 B
.github/workflows/vercel.yml 1.0 kB
.nano-staged.js 48 B
.nvmrc 6 B
.postcssrc.cjs 51 B
.prettierignore 23 B
.prettierrc 24 B
.remarkrc 159 B
.renovaterc 49 B
.simple-git-hooks.js 49 B
.size-limit.json 292 B
.yarn/plugins/plugin-prepare-lifecycle.cjs 202 B
.yarn/releases/yarn-4.9.1.cjs 3.0 MB
.yarnrc.yml 397 B
assets/pkg.svg 15.1 kB
assets/sh.png 14.4 kB
CHANGELOG.md 393 B
docs/App.tsx 1.2 kB
docs/global.css 321 B
docs/index.tsx 211 B
eslint.config.js 516 B
index.html 414 B
LICENSE 1.1 kB
package.json 3.4 kB
packages/autocorrect/CHANGELOG.md 2.2 kB
packages/autocorrect/index.d.cts 63 B
packages/autocorrect/LICENSE 1.1 kB
packages/autocorrect/package.json 1.1 kB
packages/autocorrect/README.md 4.0 kB
packages/autocorrect/src/index.ts 1.4 kB
packages/autocorrect/src/types.ts 78 B
packages/autocorrect/test/__snapshots__/fixtures.spec.ts.snap 4.7 kB
packages/autocorrect/test/fixtures.spec.ts 961 B
packages/autocorrect/test/fixtures/test.css 189 B
packages/autocorrect/test/fixtures/test.go 470 B
packages/autocorrect/test/fixtures/test.html 1.1 kB
packages/autocorrect/test/fixtures/test.md 1.1 kB
packages/autocorrect/test/fixtures/test.py 368 B
packages/autocorrect/test/fixtures/test.rb 234 B
packages/autocorrect/test/fixtures/test0.js 453 B
packages/autocorrect/tsconfig.json 154 B
packages/pkg/CHANGELOG.md 11.7 kB
packages/pkg/index.d.cts 47 B
packages/pkg/LICENSE 16.7 kB
packages/pkg/package.json 1.0 kB
packages/pkg/README.md 6.2 kB
packages/pkg/src/index.ts 1.4 kB
packages/pkg/src/rules/files.ts 1.7 kB
packages/pkg/src/rules/object.ts 899 B
packages/pkg/src/rules/sort.ts 2.4 kB
packages/pkg/src/types.ts 1.0 kB
packages/pkg/src/utils.ts 567 B
packages/pkg/test/__snapshots__/engines.spec.ts.snap 158 B
packages/pkg/test/__snapshots__/files.spec.ts.snap 173 B
packages/pkg/test/__snapshots__/test.spec.ts.snap 2.0 kB
packages/pkg/test/engines.spec.ts 417 B
packages/pkg/test/files.spec.ts 409 B
packages/pkg/test/fixtures/fixture1.json 1.0 kB
packages/pkg/test/fixtures/fixture2.json 863 B
packages/pkg/test/fixtures/fixture3.json 430 B
packages/pkg/test/test.spec.ts 2.3 kB
packages/pkg/tsconfig.json 154 B
packages/sh/CHANGELOG.md 15.0 kB
packages/sh/index.d.cts 45 B
packages/sh/LICENSE 1.1 kB
packages/sh/package.json 1.4 kB
packages/sh/README.md 10.4 kB
packages/sh/test/__snapshots__/shellscript.spec.ts.snap 394 B
packages/sh/test/error.spec.ts 482 B
packages/sh/test/fixtures.spec.ts 1.2 kB
packages/sh/test/fixtures/.dockerignore 108 B
packages/sh/test/fixtures/.nvmrc 6 B
packages/sh/test/fixtures/.properties 177 B
packages/sh/test/fixtures/133.sh 5.2 kB
packages/sh/test/fixtures/162.sh 15.7 kB
packages/sh/test/fixtures/182.sh 1.9 kB
packages/sh/test/fixtures/191.sh 1.7 kB
packages/sh/test/fixtures/278.Dockerfile 32 B
packages/sh/test/fixtures/292.Dockerfile 95 B
packages/sh/test/fixtures/376.Dockerfile 217 B
packages/sh/test/fixtures/384.Dockerfile 51 B
packages/sh/test/fixtures/398.Dockerfile 64 B
packages/sh/test/fixtures/441.Dockerfile 219 B
packages/sh/test/fixtures/445.sh 105 B
packages/sh/test/fixtures/Dockerfile 394 B
packages/sh/test/fixtures/hosts 406 B
packages/sh/test/fixtures/jvm.options 162 B
packages/sh/test/fixtures/no-ext 38 B
packages/sh/test/fixtures/shell.sh 368 B
packages/sh/test/loc-functions.spec.ts 1.2 kB
packages/sh/test/parser.spec.ts 2.1 kB
packages/sh/tsconfig.json 154 B
packages/sql/CHANGELOG.md 11.6 kB
packages/sql/index.d.cts 47 B
packages/sql/LICENSE 1.1 kB
packages/sql/package.json 1.3 kB
packages/sql/README.md 7.0 kB
packages/sql/src/index.ts 13.0 kB
packages/sql/test/__snapshots__/fixtures-eol.spec.ts.snap 886 B
packages/sql/test/__snapshots__/fixtures.spec.ts.snap 40.3 kB
packages/sql/test/__snapshots__/sql.spec.ts.snap 374 B
packages/sql/test/fixtures-eol.spec.ts 1.4 kB
packages/sql/test/fixtures-eol/556.sql 73 B
packages/sql/test/fixtures-eol/557.sql 69 B
packages/sql/test/fixtures-eol/558.sql 69 B
packages/sql/test/fixtures-eol/559.sql 73 B
packages/sql/test/fixtures.spec.ts 1.8 kB
packages/sql/test/fixtures/144.sql 68 B
packages/sql/test/fixtures/233.sql 68 B
packages/sql/test/fixtures/277.sql 88 B
packages/sql/test/fixtures/279.sql 106 B
packages/sql/test/fixtures/291.sql 1.2 kB
packages/sql/test/fixtures/334.sql 15 B
packages/sql/test/fixtures/405.sql 160 B
packages/sql/test/fixtures/basic.sql 120 B
packages/sql/test/sql.spec.ts 660 B
packages/sql/tsconfig.json 154 B
packages/toml/CHANGELOG.md 2.2 kB
packages/toml/index.d.cts 49 B
packages/toml/LICENSE 1.1 kB
packages/toml/package.json 1.1 kB
packages/toml/README.md 5.2 kB
packages/toml/src/index.ts 1.3 kB
packages/toml/src/options.ts 2.6 kB
packages/toml/src/types.ts 381 B
packages/toml/test/__snapshots__/fixtures.spec.ts.snap 493 B
packages/toml/test/fixtures.spec.ts 792 B
packages/toml/test/fixtures/comments.toml 87 B
packages/toml/test/fixtures/fixture1.toml 162 B
packages/toml/tsconfig.json 154 B
README.md 6.8 kB
scripts/format.ts 593 B
scripts/languages.ts 3.0 kB
test/global.d.ts 41 B
test/tsconfig.json 223 B
tsconfig.base.json 89 B
tsconfig.json 275 B
vercel.json 229 B
vite.config.ts 544 B
vitest.config.ts 541 B

🤖 This report was automatically generated by pkg-size-action

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 1ea6700 in 1 minute and 45 seconds. Click for details.
  • Reviewed 110 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/sh/src/index.ts:139
  • Draft comment:
    Fallback to sh printer on dockerfmt error: ensure that using 'spaceRedirects' default value (false in try vs true in fallback) is intentional and documented.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The difference in defaults appears intentional since these are two different formatters. The code already has a detailed comment explaining the fallback behavior and linking to relevant issues. The spaceRedirects difference is an implementation detail that doesn't need additional documentation. The comment is asking for confirmation/documentation which violates our rules. Maybe the different defaults could cause unexpected behavior changes when the fallback occurs? Maybe this deserves documentation for maintainers? The code already has clear comments about the fallback behavior. The different defaults are an implementation detail that doesn't affect correctness. Users can explicitly set spaceRedirects if they care about the behavior. Delete this comment. It asks for confirmation/documentation of an implementation detail that is already adequately explained in the code comments.
2. packages/sh/src/index.ts:145
  • Draft comment:
    Consider logging or preserving the dockerfmt error inside the catch block for easier debugging while falling back.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code is deliberately catching and swallowing errors from dockerfmt because it's documented as buggy (see comment). The code has an intentional fallback mechanism. Adding logging here would just add noise since we expect and handle these errors gracefully. The comment in the code already explains why errors are expected and links to relevant issues. Perhaps error logging could help debug issues with dockerfmt itself. The errors might contain useful information for the dockerfmt maintainers. The code already documents the known dockerfmt issues with links. Since this is an expected fallback path, logging errors would just add noise without providing value. The comment should be deleted. The code intentionally handles dockerfmt errors by falling back, and adding error logging would not improve the code.
3. packages/sh/test/fixtures/445.Dockerfile:1
4. packages/sh/src/index.ts:139
  • Draft comment:
    Consider capturing the thrown error (e.g. using catch (error)) and logging it for better diagnostics in the fallback case.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code intentionally handles dockerfmt errors by silently falling back to a different processor. The comment and GitHub issue links provide context for why errors are expected. Since this is a formatter/printer, logging errors would add noise without much value. The fallback behavior is the intended error handling strategy. The suggestion could help debug issues with dockerfmt. Having error logs could help identify new bugs beyond the known issues. The known bugs are already documented and linked. Adding error logging would just create noise for expected failure cases that are already handled gracefully. The comment should be deleted since the silent fallback is intentional and the error handling strategy is well documented with links to relevant issues.
5. packages/sh/src/index.ts:141
  • Draft comment:
    Verify the differing defaults for 'spaceRedirects' (false in the try branch vs true in the fallback) are intended.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% The code shows clear intent - this is a fallback mechanism where two different formatters are used. The comment in lines 147-152 explicitly states that dockerfmt is buggy and explains why there's a fallback. The different defaults appear intentional since they're using different formatters. Asking for verification adds no value since the code and comments already show this was a deliberate choice. The comment could be pointing out a potential bug if the different defaults lead to inconsistent formatting between the two paths. The code explicitly documents this as a fallback for when dockerfmt fails, so some differences in formatting are expected and acceptable. The author has clearly thought this through. Delete the comment. It asks for verification of something that is clearly intentional and well-documented in the code.
6. packages/sh/test/__snapshots__/fixtures.spec.ts.snap:76
  • Draft comment:
    Typographical error: 'get_chagned_files' should likely be 'get_changed_files'. Please correct the spelling for clarity.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. packages/sh/test/__snapshots__/fixtures.spec.ts.snap:956
  • Draft comment:
    Typographical issue: The assignment NAME= "ufc-web-client" contains an extra space. It is more conventional in shell scripts to write NAME="ufc-web-client" without a space between '=' and the value.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. packages/sh/test/__snapshots__/fixtures.spec.ts.snap:25
  • Draft comment:
    Potential typographical error: The username 'jounqin' may be a typo. If this is unintentional, please update it to the correct spelling.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_mMLTI4RgxIWRLvMB

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@JounQin JounQin changed the title fix: fallback to sh printer when dockerfmt throws fix(sh): fallback to sh printer when dockerfmt throws May 9, 2025
@JounQin JounQin merged commit 9f4a401 into master May 9, 2025
42 of 44 checks passed
@JounQin JounQin deleted the fix/fallback branch May 9, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream workaround
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bash script in markdown file gets partially deleted Errors with dockerfile parser
1 participant