Skip to content

Conversation

@Kunal1522
Copy link
Contributor

@Kunal1522 Kunal1522 commented Jan 11, 2026

Changes

Fixes #8836
This PR addresses the TODO comments in eventtype_validation.go by adding validation for the Source and Schema URI fields in EventTypeSpec.
Before: An EventType could be created with empty Source/Schema URIs (e.g., "source": ""), which would parse successfully but result in a meaningless empty URI.
After: If Source or Schema is provided (non-nil) but empty, validation will reject it with a clear error message.

What type of PR is this?

/kind cleanup

What this PR does

  • Adds validation in EventTypeSpec.Validate() to check that Source and Schema fields are not empty when provided
  • Adds corresponding test cases for empty URI validation

Which issue(s) this PR fixes

Fixes the following TODOs in the codebase:

  • // TODO validate Source is a valid URI.
  • // TODO validate Schema is a valid URI.

How was this tested?

go test -v ./pkg/apis/eventing/v1beta1/... -run TestEventType

@knative-prow knative-prow bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 11, 2026
@knative-prow
Copy link

knative-prow bot commented Jan 11, 2026

Hi @Kunal1522. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow bot requested review from Cali0707 and matzew January 11, 2026 14:35
@knative-prow
Copy link

knative-prow bot commented Jan 11, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kunal1522
Once this PR has been reviewed and has the lgtm label, please assign leo6leo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// TODO validate Schema is a valid URI.
// Validate Source is a non-empty URI when provided
if ets.Source != nil && ets.Source.IsEmpty() {
errs = errs.Also(apis.ErrInvalidValue("", "source", "source URI cannot be empty"))
Copy link
Member

Choose a reason for hiding this comment

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

ets.Source could be nil, while this error would not be set. As IsEmpty() seems also to be nil safe, you could also use ets.Source.IsEmpty() directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey thanks @creydr ! I tried removing the nil check but the existing tests started failing. IsEmpty() returns true for nil, so it was treating "not provided" the same as "provided but empty". I think we only want to error on the second case since the fields are optional. Let me know if I'm missing something though!

}
// Validate Schema is a non-empty URI when provided
if ets.Schema != nil && ets.Schema.IsEmpty() {
errs = errs.Also(apis.ErrInvalidValue("", "schema", "schema URI cannot be empty"))
Copy link
Member

Choose a reason for hiding this comment

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

same as with etc.Source & nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add URI validation for EventType Source and Schema fields

2 participants