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

Can't get an organizatio from method aws.organizations.getOrganization #497

Open
polkx opened this issue May 22, 2024 · 1 comment
Open

Comments

@polkx
Copy link
Collaborator

polkx commented May 22, 2024

When I try to get an organization from method aws.organizations.getOrganization the Error shows up about deserializing a list.

Dependencies:

//> using scala 3.3.1
//> using options -Werror -Wunused:all -Wvalue-discard -Wnonunit-statement
//> using dep org.virtuslab::besom-core:0.3.1
//> using dep org.virtuslab::besom-aws:6.31.1-core.0.3

Main class:

import besom.*
import besom.api.aws

@main def main = Pulumi.run {
  val org = aws.organizations.getOrganization(aws.organizations.GetOrganizationArgs())
  Stack.exports(organizationId = org.id)
}

Stack trace:

Diagnostics:
  pulumi:pulumi:Stack (test-dev):
    2024.05.21 13:44:14:168 main  ERROR besom.internal.BesomModule.run:70
        besom.internal.AggregatedDecodingError: Decoding Errors [3]:
          aws:organizations/getOrganization:getOrganization().accounts: Encountered an error when deserializing a list
          aws:organizations/getOrganization:getOrganization().nonMasterAccounts: Encountered an error when deserializing a list
          aws:organizations/getOrganization:getOrganization().roots: Encountered an error when deserializing a list
        (with aggregate stack trace)
                at besom.internal.AggregatedDecodingError$.apply(codecs.scala:99)
                at besom.internal.ResourceOps.decodeResponse$1$$anonfun$1(ResourceOps.scala:91)
                at besom.internal.Result.flatMap$$anonfun$1(Result.scala:166)
                at besom.internal.Result.runM$$anonfun$7(Result.scala:273)
                at besom.internal.Runtime.flatMapBothM$$anonfun$1$$anonfun$1(Result.scala:118)
                at besom.internal.FutureRuntime.flatMapBoth$$anonfun$1(Result.scala:404)
                at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:477)
                at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
                at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
                at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
                at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
                at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
                at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
        Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().accounts] aws:organizations/getOrganization:getOrganization().accounts: Encountered an error when deserializing a list
                at besom.internal.DecodingError$.apply(codecs.scala:80)
                at besom.internal.Decoder$.besom$internal$Decoder$$anon$8$$_$decode$$anonfun$4$$anonfun$3(codecs.scala:281)
                at besom.util.NonEmptyVector.map(Validated.scala:167)
                at besom.util.Validated.lmap(Validated.scala:47)
                at besom.util.Validated$.lmap$$anonfun$1(Validated.scala:137)
                at besom.internal.Result.map$$anonfun$1(Result.scala:205)
                at besom.internal.Result.flatMap$$anonfun$1(Result.scala:166)
                at besom.internal.Result.runM$$anonfun$7(Result.scala:273)
                at besom.internal.Runtime.flatMapBothM$$anonfun$1$$anonfun$1(Result.scala:118)
                at besom.internal.FutureRuntime.flatMapBoth$$anonfun$1(Result.scala:404)
                at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:477)
                at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
                at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
                at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
                at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
                at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
                at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
        Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().accounts] aws:organizations/getOrganization:getOrganization().accounts: Expected a list, got NullValue(NULL_VALUE)
                at besom.internal.DecodingError$.apply(codecs.scala:80)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4$$anonfun$1(codecs.scala:267)
                at besom.internal.OutputData.traverseValidatedResult(OutputData.scala:99)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4(codecs.scala:278)
                at besom.util.Validated$.flatMap$$anonfun$1(Validated.scala:112)
                at besom.internal.Result.flatMap$$anonfun$1(Result.scala:166)
                at besom.internal.Result.runM$$anonfun$7(Result.scala:273)
                at besom.internal.Runtime.flatMapBothM$$anonfun$1$$anonfun$1(Result.scala:118)
                at besom.internal.FutureRuntime.flatMapBoth$$anonfun$1(Result.scala:404)
                at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:477)
                at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
                at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
                at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
                at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
                at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
                at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
    Compiling project (Scala 3.3.1, JVM (21))
    Compiled project (Scala 3.3.1, JVM (21))
    Exception in thread "main" besom.internal.AggregatedDecodingError: Decoding Errors [3]:
      aws:organizations/getOrganization:getOrganization().accounts: Encountered an error when deserializing a list
      aws:organizations/getOrganization:getOrganization().nonMasterAccounts: Encountered an error when deserializing a list
      aws:organizations/getOrganization:getOrganization().roots: Encountered an error when deserializing a list
    (with aggregate stack trace)
        at besom.internal.AggregatedDecodingError$.apply(codecs.scala:99)
        at besom.internal.ResourceOps.decodeResponse$1$$anonfun$1(ResourceOps.scala:91)
        at besom.internal.Result.flatMap$$anonfun$1(Result.scala:166)
        at besom.internal.Result.runM$$anonfun$7(Result.scala:273)
        at besom.internal.Runtime.flatMapBothM$$anonfun$1$$anonfun$1(Result.scala:118)
        at besom.internal.FutureRuntime.flatMapBoth$$anonfun$1(Result.scala:404)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:477)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
    Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().accounts] aws:organizations/getOrganization:getOrganization().accounts: Encountered an error when deserializing a list
        at besom.internal.DecodingError$.apply(codecs.scala:80)
        at besom.internal.Decoder$.besom$internal$Decoder$$anon$8$$_$decode$$anonfun$4$$anonfun$3(codecs.scala:281)
        at besom.util.NonEmptyVector.map(Validated.scala:167)
        at besom.util.Validated.lmap(Validated.scala:47)
        at besom.util.Validated$.lmap$$anonfun$1(Validated.scala:137)
        at besom.internal.Result.map$$anonfun$1(Result.scala:205)
        ... 11 more
        Suppressed: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().nonMasterAccounts] aws:organizations/getOrganization:getOrganization().nonMasterAccounts: Encountered an error when deserializing a list
                ... 17 more
        Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().nonMasterAccounts] aws:organizations/getOrganization:getOrganization().nonMasterAccounts: Expected a list, got NullValue(NULL_VALUE)
                at besom.internal.DecodingError$.apply(codecs.scala:80)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4$$anonfun$1(codecs.scala:267)
                at besom.internal.OutputData.traverseValidatedResult(OutputData.scala:99)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4(codecs.scala:278)
                at besom.util.Validated$.flatMap$$anonfun$1(Validated.scala:112)
                ... 11 more
        Suppressed: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().roots] aws:organizations/getOrganization:getOrganization().roots: Encountered an error when deserializing a list
                ... 17 more
        Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().roots] aws:organizations/getOrganization:getOrganization().roots: Expected a list, got NullValue(NULL_VALUE)
                at besom.internal.DecodingError$.apply(codecs.scala:80)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4$$anonfun$1(codecs.scala:267)
                at besom.internal.OutputData.traverseValidatedResult(OutputData.scala:99)
                at besom.internal.Decoder$$anon$8.decode$$anonfun$4(codecs.scala:278)
                at besom.util.Validated$.flatMap$$anonfun$1(Validated.scala:112)
                ... 11 more
    Caused by: besom.internal.DecodingError: [aws:organizations/getOrganization:getOrganization().accounts] aws:organizations/getOrganization:getOrganization().accounts: Expected a list, got NullValue(NULL_VALUE)
        at besom.internal.DecodingError$.apply(codecs.scala:80)
        at besom.internal.Decoder$$anon$8.decode$$anonfun$4$$anonfun$1(codecs.scala:267)
        at besom.internal.OutputData.traverseValidatedResult(OutputData.scala:99)
        at besom.internal.Decoder$$anon$8.decode$$anonfun$4(codecs.scala:278)
        at besom.util.Validated$.flatMap$$anonfun$1(Validated.scala:112)
        ... 11 more
    error: an unhandled error occurred: '/opt/homebrew/bin/scala-cli /opt/homebrew/bin/scala-cli run .' exited with non-zero exit code: 1
@lbialy
Copy link
Collaborator

lbialy commented May 24, 2024

Related to #432 - same kind of issue - properties on resources are implemented as Outputs of structs, collections of structs or primitives or collections of primitives. These structs do not hold their data in Outputs - those are raw case classes. This means that their decoders are all-or-nothing and any failure trips the whole field as the error has to bubble up to the nearest Output. Solution to this is discussed in #432 - we should change our codegen to generate case classes with Output fields and fix Decoder stack to handle this properly. This in turn will allow for granular secretness control and granular control of decoding failure of some fields like in this issue (non-nullable field is null).

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

No branches or pull requests

2 participants