Skip to content

Conversation

timostamm
Copy link
Member

@timostamm timostamm commented Sep 11, 2025

Protobuf-ES can generate a Valid type that honors proto2 required and the protovalidate required rule. For messages that don't use any of the relevant annotations, we generate the valid type as an alias to the regular type to avoid unnecessary repetitions.

The logic to determine when to generate a complete valid type or just an alias is flawed: It doesn't consider the case where a message doesn't have any annotations itself, but references a message that does in a message field. In this case, we need a complete valid type, not just an alias.

Fixes #1224.

msg?: VTypes;
};

export declare type VTypes2Valid = VTypes2;
Copy link
Member Author

@timostamm timostamm Sep 11, 2025

Choose a reason for hiding this comment

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

Similar to #1224, Vtypes2Valid should be a bespoke type with a property msg?: VTypesValid.

Comment on lines +389 to +396
export declare type VTypes2Valid = Message<"spec.VTypes2"> & {
/**
* In the generated valid type, this property should point to a valid type.
*
* @generated from field: spec.VTypes msg = 1;
*/
msg?: VTypesValid;
};
Copy link
Member Author

@timostamm timostamm Sep 11, 2025

Choose a reason for hiding this comment

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

New gen code with this PR.

@timostamm timostamm merged commit cdd0dd9 into main Sep 11, 2025
22 checks passed
@timostamm timostamm deleted the tstamm/Fix-Valid-types-for-interstitial-references branch September 11, 2025 14:32
@timostamm timostamm mentioned this pull request Sep 11, 2025
@bagarinodominador7-ai
Copy link

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.

Valid types not generated for containing messages that don't have annotations
3 participants