Open Bug 779653 Opened 12 years ago Updated 9 years ago

Validate data types of input params

Categories

(Bugzilla :: WebService, enhancement)

enhancement
Not set
normal

Tracking

()

People

(Reporter: koosha.khajeh, Unassigned)

Details

Almost all web service methods that require client to pass a hash or an array will crash if the client doesn't supply the intended data type. We should check the data type and throw appropriate errors in case of invalid data types instead of crashing.
That's the job of the validators, not something to do in WS themselves. In which cases do you get a crash?
Severity: normal → enhancement
there are lots of places in the code which assume the correct datatype will be provided.
this generally happens before the validator is run.

a classic example is assuming dereferencing a variable without checking that it's a reference to the correct type:
> Can't use string ("astring") as an ARRAY ref while "strict refs" in use at Bugzilla/WebService/Bug.pm line 1251
caused by:
> foreach my $tag (@{ $params->{add} || [] }) {
You need to log in before you can comment on or make changes to this bug.