aws-samples / sample-python-helper-aws-appconfig

A Python helper library for AWS AppConfig
Apache License 2.0
31 stars 9 forks source link

update_config can cause BadRequestException #2

Closed jrobbins-LiveData closed 2 years ago

jrobbins-LiveData commented 2 years ago

The early return in update_config (to deal with empty content when the config hasn't changed)

        if content == b"":
            return False

results in this error

BadRequestException('An error occurred (BadRequestException) when calling the GetLatestConfiguration operation: Request too early')

if the next call to update_config happens soon enough after this call.

The reason the exception is raised by get_latest_configuration is that this ealy return fails to update the variable (self._last_update_time) used to guard against calling before the negotiated minimum poll set via the RequiredMinimumPollIntervalInSeconds arg to start_configuration_session.

Changing the code to

            if content == b"":
                self._last_update_time = time.time()
                return False

would fix this problem.

jamesoff commented 2 years ago

Thanks for the report!

jrobbins-LiveData commented 2 years ago

You're welcome! Thanks for the fix (along with an updated unit test!)