Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.13: [Bug]: ERR_INVALID_ARG_TYPE when garden tries to store test results when data is undefined #5561

Closed
shumailxyz opened this issue Dec 14, 2023 · 2 comments · Fixed by #6380

Comments

@shumailxyz
Copy link
Contributor

Garden Bonsai (0.13) Bug

Sometimes in running test actions, the logs show this error:

[ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

This happens if for some reason the data is null/missing and garden tries to serialize undefined data into base64.
https://github.com/garden-io/garden/blob/main/core/src/plugins/kubernetes/test-results.ts#L83

Current Behavior

It doesn't throw the error or fails because currently we catch it and log it as a warning.

Expected behavior

It shouldn't try to store undefined in configmap at all if there's no data.

Suggested solution(s)

Check why the data is undefiend in first place as the type TestResult includes timestamps of test action execution which shouldn't be null atleast.

Otherwise, also add a check in upsertConfigMap function where it serializes the data into base64.
https://github.com/garden-io/garden/blob/main/core/src/plugins/kubernetes/util.ts#L394

Additional context

Your environment

  • OS:
  • How I'm running Kubernetes:

garden version

@har-cpol
Copy link

har-cpol commented Aug 6, 2024

I ran into the same issue and did some investigation for some time.

From what I can tell, this happens if:

  • test command returns non-zero exit code
  • and there are artifacts defined in the test action.

Following is a simplified example:

kind: Test
type: kubernetes-pod
name: demo-error
spec:
  podSpec:
    containers:
      - name: test-demo-error
        image: alpine:3.20.2
        imagePullPolicy: IfNotPresent

  command: [ "/bin/sh", "-c", "echo ok >> /tmp/dummy-result.txt && exit 1" ]
  artifacts:
    - source: /tmp/dummy-result.txt
      target: demo-unit-tests
  • The example above simulates a test execution that ends with exit code 1 and has artifacts defined. This triggers the error.
  • If you change exit code to 0, it works fine.
  • If you remove the artifacts part, it works fine.

Running on:
garden: 0.13.36
Operating system: Fedora 39
Kubernetes: k0s and GKE

@twelvemo
Copy link
Collaborator

@har-cpol thanks a lot for the reproducible example! I took a closer look and found that the issue is actually caused by us trying to serialize a potentially undefined value. The linked PR should fix the isse.

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

Successfully merging a pull request may close this issue.

3 participants