crossplane-contrib / crossplane-contrib/function-go-templating
Misleading errors when using CompositeConnectionDetails
- Dominant language
- Go
- Stars
- 100
- Forks
- 65
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 9
Description
### What happened?
I defined the following CompositeConnectionDetails resource
```yaml
apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: CompositeConnectionDetails
{{ if eq $.observed.resources nil }}
data: {}
{{ else }}
data:
{{ $redisCacheMR := get .observed.resources "redis-cache" | default dict }}
{{ $connectionString := dig "connectionDetails" "attribute.primary_connection_string" "" $redisCacheMR }}
{{ $host := dig "status" "atProvider" "hostname" " " $redisCacheMR }}
connection_string: {{ $connectionString }}
host: {{ $host | b64enc }}
{{ end }}
```
When all the MR's successfully reached a ready state, the claim would fail with the following error.
> cannot propagate connection details from composite: cannot establish
> control of existing connection secret
This error was resolved by adding quotes to the host host parameter.
```yaml
...
host: {{ $host | quote | b64enc }}
...
```
This error was extremely misleading and I'm assuming thats because there's no error handling in the portion of this function which sets connection details. I'm unsure if its feasible but It might be useful to make this a little more robust by automatically quoting / encode values which aren't already in the correct format or outputting an error message.
### How can we reproduce it?
set
### What environment did it happen in?
Function version: v0.3.0
crossplane: v1.14.2
k8s: 1.26.9
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file, test, or implementation entry point is named. Start by tracing CompositeConnectionDetails connection-detail processing and reproduce the unquoted host case from the issue; done means the failure is handled robustly or reports an actionable error instead of the misleading control-of-secret message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100