Skip to content

Conversation

@RayyanSeliya
Copy link
Contributor

Changes

  • 🎁 Add early domain validation with user-friendly error messages
  • 🐛 Prevent wasted build time when using invalid domain names
  • 🧹 Add comprehensive unit tests for domain validation

Adds DNS-1123 subdomain validation for domain names before build/deploy operations. Invalid domain names now fail immediately with clear error messages instead of proceeding through lengthy builds.

Implementation:

  • Add ValidateDomain() function using Kubernetes DNS-1123 subdomain validation (pkg/utils/names.go)
  • Add validation check in deployConfig.Validate() and error handling in runDeploy() (cmd/deploy.go)
  • Add ErrInvalidDomain error type (pkg/functions/errors.go) with user-friendly CLI message
  • Add comprehensive test coverage with 49+ test cases covering valid/invalid domains

Fixes #3151

Before:

$ func deploy --registry ghcr.io/user --domain "my app.com"
Building function image
Still building
^CError: executing lifecycle: context canceled

After:

$ func deploy --registry ghcr.io/user --domain "my app.com"
Error: invalid domain

Domain names must be valid DNS subdomains:
  - Lowercase letters, numbers, hyphens (-), and dots (.) only
  - Start and end with a letter or number
  - Max 253 characters total, each part between dots max 63 characters

Valid examples:
  func deploy --registry ghcr.io/user --domain example.com
  func deploy --registry ghcr.io/user --domain api.example.com

Note: Domain must be configured on your Knative cluster, or it will be ignored.

For more options, run 'func deploy --help'

/kind enhancement

Release Note

Invalid domain names are now caught immediately with helpful error messages, preventing wasted build time

@knative-prow knative-prow bot requested review from dsimansk and nainaz October 27, 2025 18:22
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2025
@knative-prow
Copy link

knative-prow bot commented Oct 27, 2025

Hi @RayyanSeliya. 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.

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.

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.22%. Comparing base (0a41919) to head (67f7f32).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3152      +/-   ##
==========================================
+ Coverage   59.41%   60.22%   +0.81%     
==========================================
  Files         134      134              
  Lines       13495    13526      +31     
==========================================
+ Hits         8018     8146     +128     
+ Misses       4537     4408     -129     
- Partials      940      972      +32     
Flag Coverage Δ
e2e-tests 41.64% <0.00%> (+1.40%) ⬆️
integration-tests 54.67% <53.84%> (+1.68%) ⬆️
unit-tests 46.82% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: RayyanSeliya <[email protected]>
@gauron99 gauron99 requested review from matejvasek and removed request for dsimansk and nainaz October 30, 2025 17:57
@gauron99
Copy link
Contributor

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 30, 2025
@gauron99
Copy link
Contributor

gauron99 commented Nov 2, 2025

/retest

@RayyanSeliya
Copy link
Contributor Author

Hey @gauron99 I thinks it's ready now all clear !

@gauron99
Copy link
Contributor

gauron99 commented Nov 4, 2025

I think it would be better to keep the utils as small as possible, since this PR addresses domains, we need domains only in deploy so it would be better to keep the error definitions in errors and any CLI errors in cmd/deploy.go. And any validation function also to be kept the cmd/deploy.go (where its used)
WDYT @matejvasek @lkingland ?

Copy link
Member

@lkingland lkingland left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Nov 11, 2025
@knative-prow
Copy link

knative-prow bot commented Nov 11, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lkingland, RayyanSeliya

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

The pull request process is described here

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 11, 2025
@knative-prow knative-prow bot merged commit 88c40ab into knative:main Nov 11, 2025
53 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid Domain Names Bypass Validation, Waste Build Time

3 participants