bring cloud;
inflight interface MyBucketInterface {
put(): void;
}
class MyBucketImplementation impl MyBucketInterface {
bucket: cloud.Bucket;
new(bucket: cloud.Bucket) {
this.bucket = bucket;
}
inflight pub put() {
this.bucket.put("hello", "world");
}
}
inflight class Wrapper {
myBucket: MyBucketInterface;
new(myBucket: MyBucketInterface) {
this.myBucket = myBucket;
}
inflight pub put() {
this.myBucket.put();
}
}
let bucket = new cloud.Bucket();
let classA = new MyBucketImplementation(bucket);
test "test preflight" {
// Without the following statement, the test will fail with the error:
// Resource "root/env0/test:test preflight/Handler" does not have permission to perform operation "put" on resource "root/env0/Bucket".
// To avoid the error, just remove the comment below:
// bucket.put;
let wrapper1 = new Wrapper(classA);
wrapper1.put();
}
Run wing test.
This happened:
fail ┌ main.wsim » root/env0/test:test preflight
│ Error: Resource "root/env0/test:test preflight/Handler" does not have permission to perform operation "put" on resource "root/env0/Bucket".
│ --> main.w:15:7
│ | }
│ |
│ | inflight pub put() {
│ 15 | this.bucket.put("hello", "world");
│ | ^
│ at put /Users/cristian/Code/wing-error-reproduction-1/main.w:15:7
│ at put /Users/cristian/Code/wing-error-reproduction-1/main.w:26:7
└ at /Users/cristian/Code/wing-error-reproduction-1/main.w:40:4
Tests 1 failed (1)
Snapshots 1 skipped
Test Files 1 failed (1)
Duration 0m0.28s
I expected this:
Either:
The compiler should track permissions correctly
Or the compiler should warn something similar to
Expression of type "Bucket" references an unknown preflight object, can't qualify its capabilities. Use `lift()` to explicitly qualify the preflight object to disable this error.
I tried this:
Run
wing test
.This happened:
I expected this:
Either:
Which is the error we get when we do this:
Is there a workaround?
Remove the
inflight
modifier fromWrapper
(and instantiateWrapper
during preflight).Anything else?
No response
Wing Version
0.74.47
Node.js Version
No response
Platform(s)
No response
Community Notes