Skip to content

DWDS should ignore optional offset/count parameters in getObject request if the object has no length #1439

Closed
@elliette

Description

@elliette

The VM service protocol supports optional offset and count parameters in getObject.

From the VM service protocol documentation:

The offset and count parameters are used to request subranges of Instance objects with the kinds: String, List, Map, Uint8ClampedList, Uint8List, Uint16List, Uint32List, Uint64List, Int8List, Int16List, Int32List, Int64List, Flooat32List, Float64List, Inst32x3List, Float32x4List, and Float64x2List. These parameters are otherwise ignored.

However, if a client sets these optional parameters on an object that is not of one of the above listed types, DWDS throws the following exception:

getObject: NoSuchMethodError: The method '_greaterThanFromInteger' was called on null.
Receiver: null
Tried calling: _greaterThanFromInteger(0)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:68:5)
#1      int.> (dart:core-patch/integers.dart:146:18)
#2      min (dart:math-patch/math_patch.dart:20:9)
#3      Debugger._subrange (package:dwds/src/debugging/debugger.dart:368:43)
#4      Debugger.getProperties (package:dwds/src/debugging/debugger.dart:404:25)
#5      InstanceHelper.instanceFor (package:dwds/src/debugging/instance.dart:112:47)

This is because DWDS never checks whether or not the object's length is null if count and offset are set. If the object has no length, DWDS should ignore the offset and count parameters.

Code pointers:

  1. https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/debugging/instance.dart#L112-L116
  2. https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/debugging/debugger.dart#L403-L406
  3. https://github.com/dart-lang/webdev/blob/master/dwds/lib/src/debugging/debugger.dart#L368

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions