{"record":{"id":"41f5d826ce0e0564","repo":"nats-io/nats-server","slug":"unsupported-ber-encoding","errorCode":null,"errorMessage":"unsupported BER encoding","messagePattern":"unsupported BER encoding","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/ldap/dn.go","lineNumber":177,"sourceCode":"\n\t\t\tdst := []byte{0}\n\t\t\tn, err := enchex.Decode([]byte(dst), []byte(str[i:i+2]))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to decode escaped character: %s\", err)\n\t\t\t} else if n != 1 {\n\t\t\t\treturn nil, fmt.Errorf(\"expected 1 byte when un-escaping, got %d\", n)\n\t\t\t}\n\t\t\tbuffer.WriteByte(dst[0])\n\t\t\ti++\n\t\tcase char == '\\\\':\n\t\t\tunescapedTrailingSpaces = 0\n\t\t\tescaping = true\n\t\tcase char == '=':\n\t\t\tattribute.Type = stringFromBuffer()\n\t\t\t// Special case: If the first character in the value is # the following data\n\t\t\t// is BER encoded. Throw an error since not supported right now.\n\t\t\tif len(str) > i+1 && str[i+1] == '#' {\n\t\t\t\treturn nil, errors.New(\"unsupported BER encoding\")\n\t\t\t}\n\t\tcase char == ',' || char == '+':\n\t\t\t// We're done with this RDN or value, push it\n\t\t\tif len(attribute.Type) == 0 {\n\t\t\t\treturn nil, errors.New(\"incomplete type, value pair\")\n\t\t\t}\n\t\t\tattribute.Value = stringFromBuffer()\n\t\t\trdn.Attributes = append(rdn.Attributes, attribute)\n\t\t\tattribute = new(AttributeTypeAndValue)\n\t\t\tif char == ',' {\n\t\t\t\tdn.RDNs = append(dn.RDNs, rdn)\n\t\t\t\trdn = new(RelativeDN)\n\t\t\t\trdn.Attributes = make([]*AttributeTypeAndValue, 0)\n\t\t\t}\n\t\tcase char == ' ' && buffer.Len() == 0:\n\t\t\t// ignore unescaped leading spaces\n\t\t\tcontinue\n\t\tdefault:","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/internal/ldap/dn.go#L159-L195","documentation":"memStore.Snapshot is a deliberately unimplemented method in the in-memory store; it always returns a 'no impl' error. The memStore is used for ephemeral/no-persistence streams, so full snapshotting is unsupported. Callers must use EncodedStreamState instead when working with a memStore-backed stream.","triggerScenarios":"Calling Snapshot(_, _, _, _) on a *memStore instance — e.g. generic store code that snapshots all stream types without checking the storage type.","commonSituations":"Monitoring or migration tooling calling the Store interface's Snapshot method on a stream configured with memory storage; interface-level code assuming all store implementations support snapshots.","solutions":["Do not call Snapshot on memory-backed streams; use EncodedStreamState or StreamState instead","Check the store type (StorageMemory) before invoking Snapshot and skip/handle accordingly","Use the generic snapshot path only for fileStore-backed streams"],"exampleFix":"// before\nsnap, err := store.Snapshot(10*time.Second, true, true)\n// after\nif _, isMem := store.(*memStore); isMem {\n    return errors.New(\"snapshot not supported for memory streams\")\n}\nsnap, err := store.Snapshot(10*time.Second, true, true)","handlingStrategy":"fallback","validationCode":"if _, isMem := store.(*memStore); isMem {\n    // use EncodedStreamState / StreamState instead of Snapshot\n}","typeGuard":"func supportsSnapshot(s interface{}) bool {\n    _, isMem := s.(*memStore)\n    return !isMem\n}","tryCatchPattern":"snap, err := store.Snapshot(d, includeDeleted, checkMsgs)\nif err != nil && strings.Contains(err.Error(), \"no impl\") {\n    // fall back to memory-store state access\n}","preventionTips":["Check stream storage type (memory vs file) before snapshotting","Prefer interface guards (Snapshotter type assertion) over blind calls","Document that memory streams don't support snapshots in tooling"],"tags":["jetstream","unimplemented","memory-storage"],"backgroundTag":"method-not-implemented","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}