fix(provider): validate coder_app URL scheme for external apps - #541
fix(provider): validate coder_app URL scheme for external apps#541mmustafasenoglu wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Pull request overview
This PR adds plan-time validation to the coder_app resource so that when external = true, the configured url must be a fully-qualified URL with both a scheme and a host, and it expands regression coverage for invalid external URL inputs.
Changes:
- Add
CustomizeDiffvalidation forcoder_app.urlwhenexternal = true. - Add test cases for missing-scheme and missing-host external app URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| provider/app.go | Adds CustomizeDiff validation for external app URLs. |
| provider/app_test.go | Adds regression tests for invalid external URL inputs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| rawURL, ok := rd.GetOk("url") | ||
| if !ok { | ||
| return nil | ||
| } | ||
|
|
||
| rawURLStr, ok := rawURL.(string) | ||
| if !ok { | ||
| return fmt.Errorf("unexpected type %T for url, expected string", rawURL) | ||
| } | ||
|
|
||
| parsedURL, err := url.Parse(rawURLStr) | ||
| if err != nil { | ||
| return fmt.Errorf("invalid \"coder_app\" url %q for external app: %w", rawURLStr, err) | ||
| } | ||
| if parsedURL.Scheme == "" || parsedURL.Host == "" { | ||
| return fmt.Errorf("invalid \"coder_app\" url %q for external app: must include a scheme and host", rawURLStr) | ||
| } |
| `, | ||
| external: true, | ||
| }, { | ||
| name: "MissingScheme", |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks — addressed the edge cases: empty |
1 similar comment
|
Thanks — addressed the edge cases: empty |
Summary
Validate
coder_app.urlwhenexternal = trueso external apps require both a URL scheme and a host.Changes
Validation
go test ./provider/...