The @ServiceDiscoveryAttribute, @LoadBalancerAttribute, and @ServiceRegistrarAttribute annotations support a required field:
@ServiceDiscoveryAttribute(name = "address-list", description = "...", required = true)
However, this field is only used for documentation generation (DocWriter). It is completely ignored at runtime:
- The ConfigurationGenerator annotation processor does not generate any validation code for required attributes — the generated getters simply return null when a required attribute is missing.
- Provider implementations (ConsulServiceDiscoveryProvider, StaticListServiceDiscoveryProvider, etc.) do not validate required attributes either.
- Stork.createService() only validates that the service discovery type is not null, but does not check individual required attributes.
As a result, if a user omits a required configuration property, they get a confusing NullPointerException deep in the provider implementation instead of a clear error message at initialization time.
Expected behavior
When a property marked as required = true is missing or empty, Stork should fail fast during initialization with a clear error message, e.g.:
Missing required configuration property 'address-list' for service discovery 'static' on service 'my-service'
Suggested approach
The most natural place to add this validation would be in the ConfigurationGenerator annotation processor, so that generated *Configuration classes validate required attributes when they are
constructed from the parameter map. Alternatively, validation could be added in Stork.createService() by inspecting the provider's annotations.
Context
Discovered while working on #1201. The current lack of validation doesn't cause incorrect behavior — it just produces poor error messages when required properties are missing.
The @ServiceDiscoveryAttribute, @LoadBalancerAttribute, and @ServiceRegistrarAttribute annotations support a required field:
@ServiceDiscoveryAttribute(name = "address-list", description = "...", required = true)
However, this field is only used for documentation generation (DocWriter). It is completely ignored at runtime:
As a result, if a user omits a required configuration property, they get a confusing NullPointerException deep in the provider implementation instead of a clear error message at initialization time.
Expected behavior
When a property marked as required = true is missing or empty, Stork should fail fast during initialization with a clear error message, e.g.:
Missing required configuration property 'address-list' for service discovery 'static' on service 'my-service'
Suggested approach
The most natural place to add this validation would be in the ConfigurationGenerator annotation processor, so that generated *Configuration classes validate required attributes when they are
constructed from the parameter map. Alternatively, validation could be added in Stork.createService() by inspecting the provider's annotations.
Context
Discovered while working on #1201. The current lack of validation doesn't cause incorrect behavior — it just produces poor error messages when required properties are missing.