Repository navigation
fix: reject invalid WebFunction and NetworkConnector inputs; Ref the WebFunction for revision and endpoint FunctionName - #4016
Merged
seshubaws merged 2 commits intoOct 14, 2026
Conversation
seshubaws
marked this pull request as draft
October 13, 2026 23:39
…f crashing
Crashes (now InvalidDocumentException):
- is_intrinsic() with a non-string single key (e.g. EnvironmentVariables,
RevisionWeights or ReplicaRegions {1: ...}).
- ReplicaRegions IncludeRegions/ExcludeRegions that aren't lists, and
unrecognized ReplicaRegions keys of mixed types.
- Non-string EnvironmentVariables keys and RevisionWeights revision IDs.
- Non-string property names under Properties (any SAM resource).
- Non-string Globals section names.
- A null or non-object template.
WebFunction EgressNetworkConnectorArn:
- Reject a Ref or Fn::GetAtt on a network connector in the same template
unless it uses LatestVersionArn (Ref and Arn return the unversioned ARN).
- Reject non-string literals and include the expected ARN format and the
given value in the error.
NetworkConnector: name the allowed values for invalid ComputeTypes entries
and VpcConfig.NetworkProtocol instead of "value is not a valid dict".
bin/sam-translate.py exits 1 on an invalid template and no longer logs a
generator object.
seshubaws
force-pushed
the
seshub/webfunction-lnc-validation-fixes
branch
from
October 13, 2026 23:40
c0ba841 to
aec1c9b
Compare
seshubaws
marked this pull request as ready for review
October 14, 2026 00:19
seshubaws
enabled auto-merge
October 14, 2026 18:07
The revision and endpoint repeated the function name instead of Ref on the function, to work around a service bug where a FunctionName given as the function ARN could be created but not deleted. That bug is fixed. Always Ref the function (its ARN) for the revision and endpoint FunctionName, even when FunctionName is set, like AWS::Lambda::Version does. A FunctionName change then only has to be made on the AWS::Lambda::WebFunction. The AuthType casing fix and the "name" runtime attribute from the original workaround are unchanged.
seshubaws
force-pushed
the
seshub/webfunction-lnc-validation-fixes
branch
from
October 14, 2026 18:26
2c794f8 to
771b4a3
Compare
licjun
approved these changes
Oct 14, 2026
Vandita2020
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available
Description of changes
Fixes from a bug bash of
AWS::Serverless::WebFunctionwith network connectors. Invalid inputs that crashed the transform, or passed and failed later at deploy, now raiseInvalidDocumentExceptionwith a clear message.Crashes
is_intrinsic()with a non-string single key (intrinsics.py). This was reached from WebFunctionEnvironmentVariables,RevisionWeightsandReplicaRegions(for example{1: a}). The helper is shared, so every caller is fixed.ReplicaRegions.IncludeRegions/ExcludeRegionsthat aren't lists. Scalars raisedTypeError, and a string gave a misleading "Unknown region key" error.ReplicaRegionskeys of mixed types (sorted()TypeError).EnvironmentVariableskeys andRevisionWeightsrevision IDs.Properties(Resource.from_dict, affects every SAM resource).Globalssection names.Parser.validate_datatypes).WebFunction
EgressNetworkConnectorArnReforFn::GetAtton a network connector in the same template must useLatestVersionArn.RefandArnreturn the unversioned ARN, which only failed at deploy, and other attributes were accepted silently. The error points to!GetAtt <Connector>.LatestVersionArn.NetworkConnector error messages
ComputeTypesentries (for example[5]) andVpcConfig.NetworkProtocolvalues (IPv6,ipv4,4) now list the allowed values instead of "value is not a valid dict".bin/sam-translate.pyWebFunction revision and endpoint
FunctionName(partially reverts an earlier workaround)ReftheAWS::Lambda::WebFunction(its ARN), even whenFunctionNameis set, likeAWS::Lambda::Versiondoes. Renaming the function in a template then only changes the WebFunction, and the revision and endpoint follow.FunctionNamecould be created but not deleted. That bug is fixed.nameruntime attribute from the workaround are unchanged.FunctionNamedescription insam-docs.jsonnow says the revision and endpoint useRef.Not changed: checking that a referenced connector's
ComputeTypesincludesWebFunction, emptySubnetIds/SecurityGroupIds, the$LATESTqualifier, whole-list!Reffor list properties,ComputeTypesin Globals, and the recursion limit on self-referencing YAML aliases or very deep intrinsics.Description of how you validated changes
error_webfunction_egress_network_connector_reference,error_webfunction_invalid_property_types,error_network_connector_non_string_compute_type,error_globals_non_string_section. Updatederror_network_connector_invalid_protocol. Added unit tests foris_intrinsic, the parser, and valid and invalid connector references (Ref,Arn, unknown attributes).pytest tests: 4809 passed, 95.5% coverage.AWS::Lambda::WebFunction*types in us-east-2:FunctionName: create, update with new code (revision replaced) and stack delete all succeeded.FunctionName: create, then renaming onlyFunctionNamereplaced the function, revision and endpoint and deleted the old ones, then stack delete succeeded. black, ruff,mypy --strict, the JSON and YAML format checks, and the schema gate pass.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.