Fix key error with gateway, fixes #9841

Fixes #9841.