-
Notifications
You must be signed in to change notification settings - Fork 4k
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
❗ NOTICE: Python users using Schedule class in aws_events
, aws_applicationautoscaling
, aws_autoscaling
, aws_backup
, get synth-time "TypeError: ...got aws_cdk._ScheduleProxy instead" in CDK 2.97.0
#27259
Comments
I believe this is because the new |
Can confirm this is a new issue in 2.97.0 with the changes around |
Hello, |
This isnt an issue with CDK instead an issue with your environment. When downgrading you need to update your CLI version to match the correct schema, as indicated in the error message you posted. |
downgrading to 2.96.0 resolves the issues/27259 |
This is an issue with the CDK version you are using with your application. Not the CDK CLI version. |
Sorry, my problem is I don't know how to downgrade CDK library to match CDK CLI 2.96.0 Any help? |
This isn't really the right forum for support on how to use CDK and the CDK CLI since this is a bug report. I recommend checking out the CDK docs https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html for a guide on how to use CDK. |
As a note, this also impacts applicationautoscaling.Schedule; (aws-cdk-lib@2.97.0, cdk 2.94.0)
Of course, downgrading to CDK 2.96.2 works around the issue for now. In pyproject.toml, one can use:
|
Possible workaround, pinning cdk lib version in requirements.txt to 2.96.0
|
Yeah, this is due to the refactor that moved all Linked issue: |
We're working on it, thanks for the reports 👍🏻 |
cron
, expression
, rate
return aws_cdk._ScheduleProxy
aws_events.Schedule
get synth-time "TypeError: ...got aws_cdk._ScheduleProxy instead" in CDK 2.97.0
aws_events.Schedule
get synth-time "TypeError: ...got aws_cdk._ScheduleProxy instead" in CDK 2.97.0aws_events
, aws_applicationautoscaling
, aws_autoscaling
, aws_backup
, get synth-time "TypeError: ...got aws_cdk._ScheduleProxy instead" in CDK 2.97.0
|
We don't have a way of targeting specific languages, so this is going to blast all users not just python ones.
Please add your +1 👍 to let us know you have encountered this
Status: IN-PROGRESS
Overview:
In CDK 2.97.0, we released #27105: "feat(core):
Schedule
class". This broke python users of the 4 stable modules that were updated:aws_events
aws_applicationautoscaling
aws_autoscaling
aws_backup
As well as two experimental modules:
aws_scheduler_alpha
aws_synthetics_alpha
When passing in a
schedule
to any of the above modules in python,cron
,expression
,rate
,at
all returnaws_cdk._ScheduleProxy
type instead of the module specific schedule type.This was allowed because TypeScript does structural typing and we were relying on this to cast
core.Schedule
asmodule.Schedule
. jsii did not throw an error for this kind of type casting so it was allowed into v2.97.0.Complete Error Message:
Workaround:
Downgrade to CDK v2.96.2Upgrade to 2.97.1 or later
Solution:
We will revert the offending PR first. There will be a following PR to reimplement this and another PR in jsii to ensure that structural typing is caught by jsii errors.
Related Issues:
Original bug report reproduced here:
Describe the bug
When creating a
aws_events
Rule
creation fails when passingaws_cdk.aws_events.Schedule
. Thecron
,expression
,rate
methods all seem to return aaws_cdk._ScheduleProxy
type not the documented and requiredaws_cdk.Schedule
type:TypeError: type of argument schedule must be one of (aws_cdk.aws_events.Schedule, NoneType); got aws_cdk._ScheduleProxy instead
Expected Behavior
calling
aws_events.Schedule
methods should return aaws_events.Schedule
type as documented in the CDK docs and in type annotation.Current Behavior
aws_events.Schedule
method return aaws_cdk._ScheduleProxy
type. When attempting to use the Schedule constructor for a Schedule type as in the example in the docs:https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_events/Rule.html:
e.g.
This fails with the following error:
TypeError: type of argument schedule must be one of (aws_cdk.aws_events.Schedule, NoneType); got aws_cdk._ScheduleProxy instead
Reproduction Steps
Using the documented example will reproduce the error:
using
events.Schedule.expression(...)
andevents.Schedule.cron(...)
produce the same problem.Outside of a CDK application checking the return type in plain Python also shows that the method incorrectly return a
_ScheduleProxy
objectPossible Solution
No response
Additional Information/Context
using aws-cdk-lib==2.97.0 in python 3.11.4
The type annotation in the source documents the intended return type as
Schedule
as welle.g.:
CDK CLI Version
2.97.0
Framework Version
No response
Node.js Version
v18.15.0
OS
Mac OS 13.1 (22C65)
Language
Python
Language Version
3.11.4
Other information
No response
The text was updated successfully, but these errors were encountered: