Skip to content

Conversation

@Pinta365
Copy link

Summary

  • make deno publish fall back to jsr.json(c) when no publishable deno.json(c) exists, so packages that keep their metadata in jsr.json work as expected
  • surface a conflicting-publish-config diagnostic (with a hint and docs link) when both config files define package metadata, so authors resolve the ambiguity before publishing

Fixes #22651.

Testing

  • cargo test -p deno -- maybe_jsr_package_config
  • ./tools/format.js
  • ./tools/lint.js

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link

coderabbitai bot commented Nov 22, 2025

Walkthrough

This change adds workspace-level JSR package config handling into the publish flow and a new diagnostic for conflicting publish configs. It introduces maybe_jsr_package_config to locate, read, and (optionally strict-) validate jsr.json/jsr.jsonc at the workspace root. If both existing publish configs and a workspace JSR config are present, the code now aggregates specifiers, detects conflicts, and emits PublishDiagnostic::ConflictingPublishConfig before exiting. Tests were added for jsr reading, strict validation, non-strict behavior, and conflict diagnostics. The workspace dependency deno_maybe_sync was added to the workspace Cargo.toml.

Sequence Diagram

sequenceDiagram
    actor User
    participant PublishFlow as Publish Flow
    participant ConfigResolver as Config Resolver
    participant JsrHelper as maybe_jsr_package_config
    participant Diagnostics as Diagnostics

    User->>PublishFlow: start publish
    PublishFlow->>ConfigResolver: load existing publish_configs
    ConfigResolver-->>PublishFlow: publish_configs

    PublishFlow->>JsrHelper: maybe_jsr_package_config(workspace_dir, strict?)
    alt JSR config found
        JsrHelper-->>PublishFlow: JsrPackageConfig
        alt publish_configs non-empty
            PublishFlow->>PublishFlow: aggregate specifiers (sort, dedupe)
            PublishFlow->>Diagnostics: emit ConflictingPublishConfig(primary, specifiers)
            Diagnostics-->>PublishFlow: error diagnostic
            PublishFlow->>User: exit with conflict error
        else publish_configs empty
            PublishFlow->>PublishFlow: append JSR config to publish_configs
            PublishFlow->>ConfigResolver: continue publish resolution
        end
    else JSR config not found
        JsrHelper-->>PublishFlow: None
        PublishFlow->>ConfigResolver: continue with original publish_configs
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Files/areas to focus on:
    • cli/tools/publish/mod.rs: maybe_jsr_package_config implementation, integration points, sorting/dedup logic, error paths
    • cli/tools/publish/diagnostics.rs: new PublishDiagnostic::ConflictingPublishConfig variant and its methods (level, code, message, location, hint, snippet handling)
    • Tests added for jsr reading and conflict scenarios
    • cli/Cargo.toml: workspace dependency addition (deno_maybe_sync) and any effects on build/workspace resolution

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main changes: honoring jsr.json fallback and flagging config conflicts in the publish command.
Description check ✅ Passed The description directly relates to the changeset, explaining the fallback behavior for jsr.json and the conflict diagnostic that are implemented in the code changes.
Linked Issues check ✅ Passed The PR implements both requirements from issue #22651: jsr.json fallback when deno.json lacks publish options, and conflicting config diagnostic when both files define metadata.
Out of Scope Changes check ✅ Passed All changes are scoped to the publish workflow: added workspace dependency, new diagnostic variant, and jsr.json fallback logic with conflict detection.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 fdc4dc0 and 8a3e817.

📒 Files selected for processing (1)
  • cli/tools/publish/mod.rs (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cli/tools/publish/mod.rs (5)
libs/config/workspace/mod.rs (8)
  • workspace (2307-2311)
  • workspace (2312-2312)
  • default (1519-1521)
  • workspace_dir (3194-3198)
  • workspace_dir (3219-3223)
  • dir_path (1717-1719)
  • diagnostics (992-1185)
  • empty (1549-1564)
libs/maybe_sync/lib.rs (1)
  • new_rc (104-106)
cli/factory.rs (4)
  • sys (517-519)
  • default (251-253)
  • cli_options (375-386)
  • fs (509-511)
libs/config/deno_json/mod.rs (2)
  • dir_path (1435-1441)
  • read (1360-1370)
cli/tools/publish/diagnostics.rs (2)
  • message (228-275)
  • hint (430-477)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test release macos-aarch64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: build libs
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: lint debug linux-x86_64
🔇 Additional comments (4)
cli/tools/publish/mod.rs (4)

19-19: LGTM: Required imports for JSR config handling

The new imports support the jsr.json fallback feature correctly.

Also applies to: 31-31, 58-58


92-119: LGTM: Conflict detection and fallback logic implemented correctly

The two-phase approach (non-strict for conflict detection, then strict for validation) ensures jsr.json conflicts are caught before validation errors, and validation only occurs when jsr.json is the sole config. The early diagnostic return on conflict is appropriate.


1379-1418: LGTM: JSR config resolution with proper validation modes

The function correctly handles both strict and non-strict validation modes, with appropriate error messages in strict mode and graceful fallback in non-strict mode. The defensive name check after is_package() is reasonable without knowing the exact guarantees of that method.


1573-1662: LGTM: Comprehensive test coverage for JSR config handling

The tests cover the critical scenarios: successful reading, strict mode validation, non-strict fallback, and diagnostic formatting. Good use of tempdir for test isolation.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
cli/tools/publish/mod.rs (1)

1573-1625: Tests cover core scenarios.

The tests verify:

  1. Reading valid jsr.json successfully
  2. Strict mode validation (missing name errors)

Consider adding a test for non-strict mode behavior: verify that maybe_jsr_package_config with strict=false returns None (rather than erroring) when jsr.json exists but lacks required fields.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 355d899 and fdc4dc0.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • cli/Cargo.toml (1 hunks)
  • cli/tools/publish/diagnostics.rs (10 hunks)
  • cli/tools/publish/mod.rs (7 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
cli/tools/publish/diagnostics.rs (1)
cli/lsp/documents.rs (1)
  • primary_specifier (1437-1449)
cli/tools/publish/mod.rs (5)
libs/config/workspace/mod.rs (6)
  • workspace (2307-2311)
  • workspace (2312-2312)
  • default (1519-1521)
  • dir_path (1717-1719)
  • diagnostics (992-1185)
  • empty (1549-1564)
libs/maybe_sync/lib.rs (1)
  • new_rc (104-106)
cli/factory.rs (2)
  • sys (517-519)
  • default (251-253)
libs/config/deno_json/mod.rs (2)
  • dir_path (1435-1441)
  • read (1360-1370)
cli/tools/publish/diagnostics.rs (2)
  • message (228-275)
  • hint (430-477)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test release linux-x86_64
  • GitHub Check: test debug linux-aarch64
  • GitHub Check: test debug macos-aarch64
  • GitHub Check: test debug linux-x86_64
  • GitHub Check: test debug windows-x86_64
  • GitHub Check: test debug macos-x86_64
  • GitHub Check: lint debug windows-x86_64
  • GitHub Check: lint debug macos-x86_64
  • GitHub Check: lint debug linux-x86_64
  • GitHub Check: build libs
🔇 Additional comments (7)
cli/Cargo.toml (1)

80-80: LGTM - Dependency is properly utilized.

The deno_maybe_sync dependency is used in cli/tools/publish/mod.rs (line 31) for the new_rc utility function that wraps config objects.

cli/tools/publish/diagnostics.rs (2)

145-148: LGTM - New diagnostic variant added.

The ConflictingPublishConfig variant is properly structured with both a primary specifier for error location and a full list of conflicting specifiers for the message.


200-200: LGTM - Complete and consistent diagnostic implementation.

The new diagnostic is fully integrated across all trait methods (level, code, message, location, snippet, hint, docs_url) following the existing patterns in this file.

Also applies to: 222-224, 266-273, 347-351, 426-426, 473-475, 610-612

cli/tools/publish/mod.rs (4)

19-19: LGTM - Imports are properly used.

All three imports are utilized in the new maybe_jsr_package_config function and tests.

Also applies to: 31-31, 58-58


92-119: Conflict detection logic is sound, but consider error handling clarity.

The two-phase approach is correct:

  1. When publish_configs exist (from deno.json), check for jsr.json conflicts without requiring it to be valid (strict=false)
  2. When no publish configs exist, look for jsr.json and require it to be valid (strict=true)

However, note that when strict=false (line 95), the function will still error on JSON parse errors or I/O errors - it only skips files that are valid JSON but lack required fields. This means if a user has a malformed jsr.json alongside a valid deno.json, publishing will fail. This might be intentional (invalid jsr.json should always be flagged), but consider if this is the desired UX.

Verify this behavior is acceptable: Should a malformed jsr.json block publishing when deno.json is the intended config?


379-418: LGTM - Helper function correctly implements fallback logic.

The function properly handles both strict and non-strict modes:

  • Non-strict mode: Returns None if jsr.json/jsr.jsonc don't exist or lack required fields (name/exports)
  • Strict mode: Errors if files exist but lack required fields

The iteration over both "jsr.json" and "jsr.jsonc" ensures .jsonc fallback works as expected.


1627-1640: LGTM - Diagnostic test verifies message formatting.

The test confirms the diagnostic lists all conflicting specifiers in the message and provides an appropriate hint.

@Pinta365
Copy link
Author

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Nov 22, 2025

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue 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 evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @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 generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to 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 or @coderabbit 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.
  • You can also validate your configuration using the online YAML validator.
  • 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

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@Pinta365
Copy link
Author

Actionable comments posted: 0

🧹 Nitpick comments (1)

cli/tools/publish/mod.rs (1)> 1573-1625: Tests cover core scenarios.

The tests verify:

  1. Reading valid jsr.json successfully
  2. Strict mode validation (missing name errors)

Consider adding a test for non-strict mode behavior: verify that maybe_jsr_package_config with strict=false returns None (rather than erroring) when jsr.json exists but lacks required fields.

📜 Review details

@coderabbitai I added a test as a reference to the nitpick comment, (8a3e817). Review it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the diff for commit 8a3e817 to see what test was added
git show 8a3e817

Length of output: 1257


@Pinta365, the test looks good! It correctly addresses the nitpick by verifying that maybe_jsr_package_config with strict=false returns None when jsr.json exists but lacks the required name field. The test:

✅ Creates a jsr.json with only a version field (missing name)
✅ Calls the function with strict=false
✅ Asserts the result is None rather than an error

The implementation is clean and the test name clearly describes the expected behavior. This completes the test coverage for the non-strict mode fallback scenario.

@bartlomieju bartlomieju requested a review from dsherret November 26, 2025 09:11
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look like it will work when publishing a workspace. For example, someone might publish a workspace with members containing a deno.json and jsr.json -- Maybe we need more of a first class solution in libs/config instead of trying to fix this in the cli.

Copy link
Member

@dsherret dsherret Nov 29, 2025

Choose a reason for hiding this comment

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

For example, maybe we can get rid of additional_config_file_names and instead have a more specific discover_jsr_config: true flag that will surface a WorkspaceDiagnostic for this scenario.

Related is my comment here: https://github.com/denoland/deno/pull/31383/files#r2572813359 -- fixing that will help fix this.

Copy link
Author

Choose a reason for hiding this comment

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

Ahh yes, I see what you mean with workspaces. This only works as a solution for the root package basically.

);
}

fn maybe_jsr_package_config(
Copy link
Member

@dsherret dsherret Nov 29, 2025

Choose a reason for hiding this comment

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

maybe_package_config() on WorkspaceDirectory needs to be the source of truth for JsrPackageConfig. That way, someone using workspace_directory.maybe_package_config() will always get the right information (so, in other words, we should remove this function and make this work in WorkspaceDirectory.maybe_package_config())

For example, right now cli/tools/lint/mod.rs calls workspace_directory.maybe_package_config() and right now in this PR it's not getting the right information.

Copy link
Author

Choose a reason for hiding this comment

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

I'll go back to the drawing table and come back with a suggested solution based on this input. Thanks for the review so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deno publish not using jsr.json when deno.json exists

3 participants