Skip to content

fix: ignore protobuf files without messages when generating code#210

Merged
wmorgan6796 merged 3 commits intoCrowdStrike:mainfrom
infastin:fix/empty-files
Mar 13, 2026
Merged

fix: ignore protobuf files without messages when generating code#210
wmorgan6796 merged 3 commits intoCrowdStrike:mainfrom
infastin:fix/empty-files

Conversation

@infastin
Copy link
Copy Markdown
Contributor

@infastin infastin commented Feb 28, 2026

fastmarshal at the moment generates empty files if a protobuf file doesn't contain any messages.

So, for this file:

syntax = "proto3";

package nats;

import "google/protobuf/descriptor.proto";

option go_package = "natspb";

extend google.protobuf.FieldOptions {
  int32 subject = 123;
}

fastmarshal generates this:

// GENERATED CODE - DO NOT EDIT
// This file was generated by protoc-gen-fastmarshal

package natspb

import (
	"fmt"
	"sync/atomic"
	"github.com/CrowdStrike/csproto"
)

This PR makes it so fastmarshal first checks if there are any messages in a protobuf file before generating the code. grpc and drpc generators do the same thing.

Copy link
Copy Markdown
Contributor

@wmorgan6796 wmorgan6796 left a comment

Choose a reason for hiding this comment

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

Overall looks good. There are 2 things:

  1. It feels like there needs to be a test case added somewhere for this (I'm not entirely sure where though) to validate the new behavior.
  2. There is a typo (that was there from the moved function before) that should be fixed.

infastin and others added 2 commits March 8, 2026 14:53
Co-authored-by: William Morgan <william@morgan-fam.com>
@infastin
Copy link
Copy Markdown
Contributor Author

infastin commented Mar 8, 2026

Added a test to cmd/protoc-gen-fastmarshal.

@infastin infastin requested a review from wmorgan6796 March 8, 2026 10:17
Copy link
Copy Markdown
Contributor

@wmorgan6796 wmorgan6796 left a comment

Choose a reason for hiding this comment

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

Looks Good! thank you for the contribution!!

@wmorgan6796 wmorgan6796 merged commit e9cb63f into CrowdStrike:main Mar 13, 2026
@infastin infastin deleted the fix/empty-files branch March 13, 2026 22:15
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