Skip to content

False warning for assumed (required) ID of entity state with the int32 type #161

Open
@alexander-yevsyukov

Description

@alexander-yevsyukov

An ID field of an entity state is assumed to be (required). We don't have to declare such a field with the option explicitly.

An ID could be of int32 or other type which could not have the (required) option because of the nature of the type. If this is such a case, we should not emit the warning to console, but we do. Here's what the build of core-java produces:

`CommandRouting` should > apply custom route() STANDARD_ERROR
    Nov 25, 2024 7:09:00 PM io.spine.validate.option.Required checkUsage
    WARNING: The field `spine.test.route.RegisterUser.id` has the type UINT64 and should not be declared as `(required)`.

This happens because the stub entity state used in the CommandRoutingRejectionTest is declared like this:

message NumberStats {
    option (entity).kind = VIEW;
    int32 number = 1;
    int32 count = 2;
}

Validation should not cause console warnings for IDs being of primitive types.

The issue with the warning text

Another aspect of this issue is the test of the warning message. Now it says:

The field `spine.test.route.RegisterUser.id` has the type UINT64 and should not be declared as `(required)`.

The text is misleading. The entity state does not have the (required option. The field is assumed to be required because it's the convention for entity states that we have. The text of the warning should be updated in the scope of addressing the issue.

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions