Skip to content

fix(internal/librarian/dart): add Protobuf specification check#3965

Merged
jameslynnwu merged 8 commits intomainfrom
confirm-dart
Feb 11, 2026
Merged

fix(internal/librarian/dart): add Protobuf specification check#3965
jameslynnwu merged 8 commits intomainfrom
confirm-dart

Conversation

@jameslynnwu
Copy link
Copy Markdown
Contributor

Add check toModelConfig function to ensure that the specification format is set to "protobuf" for dart. This will prevent unsupported formats like OpenAPI from being processed by the Dart generator.

A check is added to the toModelConfig function to ensure that the
specification format is set to "protobuf". This will prevent unsupported
formats like OpenAPI from being processed by the Dart generator.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a check to ensure that Dart generation only processes Protobuf specifications, preventing unsupported formats. The implementation is correct, and a corresponding test case has been added. My review includes a suggestion to refactor the test logic to make it more robust and align better with standard Go testing patterns, ensuring clearer and more accurate test failure reporting. This suggestion aligns with general good practices and is not affected by the provided rules.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.26%. Comparing base (b477cb2) to head (c2b2fe5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3965   +/-   ##
=======================================
  Coverage   83.26%   83.26%           
=======================================
  Files          76       76           
  Lines        6418     6418           
=======================================
  Hits         5344     5344           
  Misses        701      701           
  Partials      373      373           

☔ 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.

@jameslynnwu jameslynnwu marked this pull request as ready for review February 10, 2026 20:51
@jameslynnwu jameslynnwu requested a review from a team as a code owner February 10, 2026 20:51
@jameslynnwu jameslynnwu enabled auto-merge (squash) February 10, 2026 22:00
Copy link
Copy Markdown
Contributor

@JoeWang1127 JoeWang1127 left a comment

Choose a reason for hiding this comment

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

Why is this check needed? What if Dart decided to support openAPI and we just remove the check?

@jameslynnwu
Copy link
Copy Markdown
Contributor Author

Yes, I think we should catch invalid config as soon as possible.

@jameslynnwu jameslynnwu marked this pull request as draft February 11, 2026 17:24
auto-merge was automatically disabled February 11, 2026 17:24

Pull request was converted to draft

@jameslynnwu jameslynnwu marked this pull request as ready for review February 11, 2026 19:59
Copy link
Copy Markdown
Contributor

@JoeWang1127 JoeWang1127 left a comment

Choose a reason for hiding this comment

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

Could you change the title to internal/librarian/dart?

@jameslynnwu jameslynnwu changed the title fix(dart): add Protobuf specification check fix(internal/librarian/dart): add Protobuf specification check Feb 11, 2026
@jameslynnwu jameslynnwu merged commit c0735c0 into main Feb 11, 2026
17 checks passed
@jameslynnwu jameslynnwu deleted the confirm-dart branch February 11, 2026 20:50
suztomo added a commit to suztomo/librarian that referenced this pull request Feb 12, 2026
…#2670)

This PR moves Java Librarian container implementation WIP from
`github.com/googleapis/sdk-platform-java/internal/librariangen` to
`github.com/googleapis/librarian/internal/container/java` while
preserving the git history.

Here are the steps that were followed:

```
# 1. Clone the source repository
git clone [email protected]:googleapis/sdk-platform-java.git
cd sdk-platform-java

# 2. Filter the repository to keep only the 'internal/librariangen' subdirectory
git filter-repo --subdirectory-filter internal/librariangen/ --force

# 3. Go back to the parent directory
cd ..

# 4. Clone the destination repository
git clone [email protected]:googleapis/librarian.git
cd librarian

# 5. Create a new branch for the migration
git checkout -b feat/migrate-librariangen-java main

# 6. Add the filtered repository as a remote
git remote add sdk-platform-java-librariangen ../sdk-platform-java
git fetch sdk-platform-java-librariangen

# 7. Merge the histories. This command creates a merge commit but keeps the content of the 'librarian' repository.
git merge --allow-unrelated-histories --no-ff sdk-platform-java-librariangen/main -s ours --no-commit

# 8. Read the tree from the filtered repository into the desired subdirectory
git read-tree --prefix=internal/container/java/ -u sdk-platform-java-librariangen/main

# 9. Commit the changes
git commit -m "feat(internal/container/java): migrate librariangen from sdk-platform-java"
```

Since we are still in early stages of implementing the Java container,
the plan is to squash-and-merge this PR.

original commits:
```
commit 0a1bbea44d6a1b024c569db89fef8d08ad7bd2d2
Author: Tomo Suzuki <[email protected]>
Date:   Thu Oct 23 23:58:54 2025 -0400

    chore(librariangen): Generate to use languagecontainer.Run (googleapis#3968)

commit 452d703b703ab3222fd1a7060ed5e1ac6363322b
Author: Mike Eltsufin <[email protected]>
Date:   Thu Oct 23 17:08:42 2025 -0400

    feat(librariangen): generate grpc stubs and resource helpers (googleapis#3967)
    
    *   Introduces the generation of gRPC stubs and resource helpers.
    * Modifies the `Generate` function to create output directories for
    GAPIC, gRPC, and proto files.
    * Updates the `invokeProtoc` function to pass an `OutputConfig` struct.
    * Updates the `restructureOutput` function to handle gRPC stubs and
    resource names.
    * Adds a `copyAndMerge` function to merge resource name files into the
    proto destination.
    * Updates the `cleanupIntermediateFiles` function to remove the GAPIC,
    gRPC, and proto directories.
    *   Updates tests to reflect these changes.
    *   Improvements in error handling.

commit a26a6d937e0523b9a6c193504645f96649e48573
Author: Tomo Suzuki <[email protected]>
Date:   Thu Oct 23 10:15:24 2025 -0400

    chore(librariangen): languagecontainer package to parse release-init request (googleapis#3965)
    
    Introducing languagecontainer package.
    
    * **New languagecontainer package**: A new `languagecontainer` package
    has been introduced to encapsulate language-specific container
    operations and command execution logic, promoting modularity. This
    package parses the request JSON file and calls the
    corresponding implementation method in each language container. The
    languagecontainer package itself should not have language-specific
    implementation.
    
    * **release-init command parsing**: The `languagecontainer.Run` function
    now includes robust logic to parse `release-init` requests from JSON
    files, handle command-line flags, and invoke the `ReleaseInit` function.
    * Why isn't this providing an interface? It's because if
    `LanguageContainer` is an interface, then there would be package name
    conflict of `languagecontainer/release` package (language agostic) and
    `release` package (language-specific. In this case Java-specific). [Here
    is a piece of
    code](googleapis#2516 (comment)).
    * **Main command dispatch refactor**: The `librariangen` `main.go` has
    been refactored to delegate non-`generate` commands to the new
    `languagecontainer.Run` function, centralizing command execution and
    wiring up `release.Init` for the `release-init` command.
    * **message.Change struct update**: The `SourceCommitHash` field in the
    `message.Change` struct has been renamed to `CommitHash` for improved
    clarity and consistency. This is due to the recent renaming of the field
    and
    [google-cloud-go/internal/librariangen/request.Change](https://github.com/googleapis/google-cloud-go/blob/7a85df39319e3a4870d4ad413f714ae5edd78ac8/internal/librariangen/request/request.go#L60)
    already has the field.
    
    The user (Java's language container in this case) doesn't have to
    implement the parsing logic and the tests. I moved the argument parsing
    tests to languagecontainer/languagecontainer_test.go from main_test.go.

commit f22935d55d811acfa6903f9778d02b94aed34d13
Author: Tomo Suzuki <[email protected]>
Date:   Mon Oct 20 21:57:59 2025 -0400

    chore(librariangen): introduce message package and add ReleaseInitRequest (googleapis#3958)

commit 2f6c75da3021d030c7a192f1fbb4b30908ef9dad
Author: Mike Eltsufin <[email protected]>
Date:   Fri Oct 17 11:29:31 2025 -0400

    feat(librariangen): add generate package (googleapis#3952)
    
    Based on
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen/generate
    with adaptation for Java.
    
    Currently it's just the scaffolding and more work is needed to generate
    a usable GAPIC library.
    
    The `generate` package contains the core logic for the generation
    process, including:
    - Reading and parsing the `generate-request.json` from librarian.
    - Parsing `BUILD.bazel` files in the googleapis repository to extract
    GAPIC configuration.
    - Building and executing `protoc` with the `gapic-generator-java`
    plugin.
    - Unzipping and restructuring the generated files into the final library
    layout.
    
    A `run-generate-library.sh` script is included for local development and
    end-to-end testing of the generation process.
    
    Additionally, a `go.work` file has been added to the root of the
    repository to support the multi-module workspace structure.

commit feabef32c4c45be0fb1db3615568365b902ece24
Author: Mike Eltsufin <[email protected]>
Date:   Thu Oct 16 10:25:53 2025 -0400

    feat(librariangen): add bazel package (googleapis#3940)
    
    Based on
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen/bazel
    with adaptation for Java.

commit 598de0697957ea3b05b1347c0898108648c3d7d1
Author: Mike Eltsufin <[email protected]>
Date:   Mon Oct 13 13:37:41 2025 -0400

    feat(librariangen): add protoc package (googleapis#3935)
    
    This will be used for constructing the protoc command for generating
    Java GAPICs.
    
    Based on
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen/protoc
    with the following important changes:
    * The `Build` function in `protoc.go` is updated to construct the
    `protoc` command with the correct arguments for Java GAPIC generation.
    * The tests in `protoc_test.go` are updated to reflect the changes in
    `protoc.go`.
    * The `gapicImportPath` is removed from the test configuration, as it is
    not relevant for Java.'
     * The testdata is included with modifications for Java.

commit f32325e1d04a804e881b08091704a81c29461eb7
Author: Mike Eltsufin <[email protected]>
Date:   Mon Oct 13 10:46:41 2025 -0400

    test(librariangen): add codecov and improve main.go coverage (googleapis#3936)
    
    Refactors the main function to be more testable by extracting the logic into a `runCLI` function.
    
    The logging setup is also extracted into a `parseLogLevel` function to allow for easier testing.
    
    This change increases the test coverage of main.go from 65.5% to 96.9%.

commit fe44aede2aba9627db4aa0397d2ac4de353cea03
Author: Mike Eltsufin <[email protected]>
Date:   Fri Oct 10 20:01:26 2025 -0400

    feat(librariangen): add request package (googleapis#3933)
    
    This will be used for parsing Librarian CLI requests.
    
    Copied from
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen/request.

commit f6b0b47a14eddd9c76540362b5922a5acc56b5d4
Author: Mike Eltsufin <[email protected]>
Date:   Fri Oct 10 20:01:07 2025 -0400

    feat(librariangen): add execv package (googleapis#3932)
    
    This will be used for executing commands like protoc.
    
    Copied from
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen/execv.

commit 4c5a1c417a7033deb82039239728309b35e3e70b
Author: Tomo Suzuki <[email protected]>
Date:   Thu Oct 9 16:05:42 2025 -0400

    build: AR exit gate YAML to declare dependencies.gitSource (googleapis#3929)
    
    This should suppress the warning in b/450542318.

commit 8f7ef85481fd9a926abcabb6de6451cd5f5faeee
Author: Tomo Suzuki <[email protected]>
Date:   Wed Oct 8 17:18:00 2025 -0400

    build: prepare Cloud Build YAML file for librarian-java (googleapis#3928)

commit 29d188d20e530570f46774b37d88703822774a33
Author: Mike Eltsufin <[email protected]>
Date:   Wed Oct 8 13:32:54 2025 -0400

    feat(librariangen): scaffold Java language container for Librarian (googleapis#3926)
    
    This change introduces the initial scaffolding for `librariangen`, a
    containerized Go application that will serve as the Java-specific code
    generator within the Librarian pipeline.
    
    The primary goal of this change is to establish the foundational
    components for the Java language container, including:
    * A new `librariangen` CLI application: Written in Go, this will be the
    entry point for Java code generation tasks invoked by Librarian. It
    currently includes basic command dispatching and support for
    `--version`.
    * A multi-stage `Dockerfile`: This creates a minimal container image for
    librariangen.
    * Unit tests and CI: A new GitHub Actions workflow has been added to
    build and test the librariangen executable.
    
    This scaffolding is the first step in implementing the full code
    generation logic within the Librarian system, eventually replacing the
    Java hermetic code generation system.
    
    The code is largely adapted from the Go language container at
    https://github.com/googleapis/google-cloud-go/tree/main/internal/librariangen.
    
    Fixes: googleapis#2500
```

---------

Co-authored-by: Tomo Suzuki <[email protected]>
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.

2 participants