Skip to content

Commit

Permalink
Return CONSTRAINT_ERROR on user labels that are too long (instead of …
Browse files Browse the repository at this point in the history
…FAILURE) (#20553)

* Mark constraint error as the error to return on overly long values

* Zap regen

* Fix return code

* Update TC-ULABEL-2.3 for using constraint_error

* Zap regen
  • Loading branch information
andy31415 authored and pull[bot] committed Jul 20, 2023
1 parent b3d8525 commit 2327496
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/app/clusters/user-label-server/user-label-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath &
LabelList::TypeInfo::DecodableType decodablelist;

ReturnErrorOnFailure(aDecoder.Decode(decodablelist));
ReturnErrorCodeIf(!IsValidLabelEntryList(decodablelist), CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorCodeIf(!IsValidLabelEntryList(decodablelist), CHIP_IM_GLOBAL_STATUS(ConstraintError));

auto iter = decodablelist.begin();
while (iter.Next())
Expand All @@ -146,7 +146,7 @@ CHIP_ERROR UserLabelAttrAccess::WriteLabelList(const ConcreteDataAttributePath &
Structs::LabelStruct::DecodableType entry;

ReturnErrorOnFailure(aDecoder.Decode(entry));
ReturnErrorCodeIf(!IsValidLabelEntry(entry), CHIP_ERROR_INVALID_ARGUMENT);
ReturnErrorCodeIf(!IsValidLabelEntry(entry), CHIP_IM_GLOBAL_STATUS(ConstraintError));

return provider->AppendUserLabel(endpoint, entry);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/suites/TestUserLabelClusterConstraints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests:
},
]
response:
error: FAILURE
error: CONSTRAINT_ERROR

- label: "Attempt to write overly long item for value"
command: "writeAttribute"
Expand All @@ -54,4 +54,4 @@ tests:
},
]
response:
error: FAILURE
error: CONSTRAINT_ERROR
4 changes: 2 additions & 2 deletions src/app/tests/suites/certification/Test_TC_ULABEL_2_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tests:
},
]
response:
error: FAILURE
error: CONSTRAINT_ERROR

- label: "TH reads LabelList attribute of the DUT"
PICS: ULABEL.S.A0000
Expand All @@ -59,4 +59,4 @@ tests:
},
]
response:
error: FAILURE
error: CONSTRAINT_ERROR
8 changes: 4 additions & 4 deletions zzz_generated/chip-tool/zap-generated/test/Commands.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2327496

Please sign in to comment.