Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

Fix httpRoute port property to be integer instead of string

Fixes an issue where the httpRoute port property was being rendered as a string ("8080") instead of an integer (8080), causing Gateway API validation errors when deploying with Terraform's helm_release.

Changes Made

  • Created custom helper function (application.httpRoute.rules) in _helpers.tpl that:
    • Processes httpRoute rules and ensures port values are cast to integers using the | int filter
    • Adds port validation (1-65535 range) with clear error messages
    • Supports additional HTTPRoute fields (sessionAffinity, timeouts, kind, group)
  • Updated httproute.yaml template to use the new helper function instead of the generic application.tplvalues.render
  • Restored dynamic port selection from service.ports configuration in values.yaml using template expression
  • Added test case to verify the port renders as an integer when using template expressions
  • Updated README documentation to reflect the changes

Solution

The helper function takes the rules from values.yaml, renders any template expressions using application.tplvalues.render, then parses the YAML and iterates through each rule. When outputting backendRefs, it explicitly casts the port field to integer: port: {{ .port | int }}. This ensures that even if the port comes from a template expression (which returns a string), it's converted to an integer in the final rendered output.

The port value now dynamically picks up the first service port ({{ (first $.Values.service.ports).port }}) while rendering as an integer type.

Testing

  • ✅ All 292 existing tests pass
  • ✅ New test case verifies port renders as integer 8080, not string "8080"
  • ✅ Manual testing confirms port dynamically picks up service.ports[0].port value
  • ✅ Tested with different port values (3000, 8080) to verify dynamic behavior
  • ✅ Port validation correctly rejects invalid ports (e.g., 99999)
  • ✅ Chart lints successfully
Original prompt

This section details on the original issue you should resolve

<issue_title>httpRoute: problem in the port property</issue_title>
<issue_description>Describe the bug
when using chart in terraform with helm_release, it is showing error.

To Reproduce
Steps to reproduce the behavior:

  1. in terraform, create helm_release with chart version 6.14.0
  2. use simple service and httpRoute (without rules) [values using yamlencode]
  3. try terraform apply

Expected behavior
it should apply terraform without any error and should pick correct port in httpRoute from service.

Actual behavior
throwing error --
Error: cannot patch "helm-release-name" with kind HTTPRoute: HTTPRoute.gateway.networking.k8s.io "helm-release-name" is invalid: [spec.rules[0].backendRefs[0].port: Invalid value: "string": spec.rules[0].backendRefs[0].port in body must be of type integer: "string", : Invalid value: null: some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 7, 2026 16:17
Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com>
Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com>
@aslafy-z aslafy-z closed this Feb 7, 2026
Copilot AI requested a review from aslafy-z February 7, 2026 16:19
Copilot stopped work on behalf of aslafy-z due to an error February 7, 2026 16:19
@aslafy-z aslafy-z reopened this Feb 7, 2026
@aslafy-z
Copy link
Collaborator

aslafy-z commented Feb 7, 2026

@copilot continue

Copilot AI and others added 2 commits February 7, 2026 16:25
…vice port

Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com>
…TPRoute fields

Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 7, 2026

@copilot continue

Done! The httpRoute port issue is now fixed. The port will render as an integer (not a string) and dynamically picks up the value from service.ports[0].port.

Changes made:

  • Created a helper function that processes httpRoute rules and casts port values to integers
  • Added port validation (1-65535 range)
  • Added support for additional HTTPRoute fields (sessionAffinity, timeouts, kind, group)
  • All 292 tests pass

The fix is in commits 440c713 and ddae7f1.

Copilot AI changed the title [WIP] Fix httpRoute problem in the port property Fix httpRoute port property to render as integer instead of string Feb 7, 2026
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.

httpRoute: problem in the port property

2 participants