#Secret not resolved?

1 messages · Page 1 of 1 (latest)

tropic agate
#

I have the following function, which is supposed to connect to an API (a forgejo/gitea instance), but the secret containing the auth token isn't resolved, it's just blank?

I've based this on the example in the cookbook. I've also tried injecting the secret like for docker builds, still the same issue.

Code: https://pastebin.com/kiyRjY67

How I test the function:

dagger call --verbose get-latest-version --url="https://gitea.example.com/" --owner="foobar" --name="hhkb_ansi_32u4_oscarcarlsson.hex" --token=file:./.token

The error message:

✘ QmkFirmware.getLatestVersion(
    name: "hhkb_ansi_32u4_oscarcarlsson.hex"
    owner: "keebs"
    token: ✔ setSecret(name: ""): Secret! 0.0s
    url: "https://gitea.spindeltax.net/"
  ): String! 4.8s
! call function "get_latest_version": process "/runtime" did not complete successfully: exit code: 1
┃ ╭─ Error ──────────────────────────────────────────────────────────────────────╮
┃ │ Function execution error: 'str' object has no attribute 'get'                │
┃ ╰──────────────────────────────────────────────────────────────────────────────╯
  ✔ Container.from(address: "alpine:latest"): Container! 1.0s
    ✔ resolving docker.io/library/alpine:latest 1.0s
  ✔ Container.withExec(args: ["apk", "add", "curl"]): Container! 1.4s
  ✔ Container.withExec(args: ["sh", "-c", "curl \"$URL/api/v1/packages/$OWNER\" --header \"Authorization: token $GITEA_TOKEN\""], expand: true): Container! 1.6s
  ✔ Container.stdout: String! 1.7s

Full trace at https://dagger.cloud/foobar/etc

Error: response from query: input: qmkFirmware.getLatestVersion resolve: call function "get_latest_version": process "/runtime" did not complete successfully: exit code: 1

Stderr:
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Function execution error: 'str' object has no attribute 'get'                │
╰──────────────────────────────────────────────────────────────────────────────╯

Any ideas?

rare steppe
#

it looks like versions is a List[str]? and so doesn't have a property called get?

#

it looks like the secret propagation is working (that looks right to me)

#

that bit seems to be working since you're getting to line 36

tropic agate
#

I seem to have missed the stdout from running the above,

{"message":"token is required","url":"https://gitea.example.com/api/swagger"}

#

I use some list comprehensions on versions later in the function, after converting it to json

rare steppe
#

does your .token actually contain the token? just to confirm?

#

can you try doing something else with the token? just wanting to make sure it's not something like an issue with the api

#

how do you know that the secret is blank essentially

tropic agate
#

I can call the API with the access token as a GET-parameter, and after looking at the access log it looks like this:

router: completed GET /api/v1/packages/foobar?access_token= for 1.2.3.4:0, 401 Unauthorized in 0.8ms @ v1/api.go:330(v1.Routes.func2.11.reqToken.2)

#

this time I tried with --token=env:GITEA_TOKEN (yes it is set) and with --token=file:./.token, the latter just contains the token on a single line (unsure how dagger handles newlines in this case)

tropic agate
rare steppe
#

hm

#

yeah, okay, this is a regression

#

opening an issue to continue this discussion

#

oh wait

#

yeah, you need to just not set expand

#

setting expand means that dagger is expanding it in place

#

you should instead let the shell do the expansion

tropic agate
#

ah YES THANK YOU 😄

#

I must have added expand during some other troubleshooting

#

thank you very much!

rare steppe
#

no worries 😄