{"record":{"id":"0dfc13a5bc52efbd","repo":"shadow1ng/fscan","slug":"oracle-data-type-negotiation-expected-message-2-g","errorCode":null,"errorMessage":"oracle data type negotiation expected message 2, got %d","messagePattern":"oracle data type negotiation expected message 2, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/oracle_raw.go","lineNumber":1121,"sourceCode":"\t\tfor _, v := range typeReps {\n\t\t\ts.putBytes(uint8(v))\n\t\t}\n\t\ts.putBytes(0)\n\t} else {\n\t\tfor _, v := range typeReps {\n\t\t\ts.putInt(v, 2, true, false)\n\t\t}\n\t\ts.putBytes(0, 0)\n\t}\n\tif err := s.writeData(); err != nil {\n\t\treturn err\n\t}\n\tmsg, err := s.getByte()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif msg != 2 {\n\t\treturn fmt.Errorf(\"oracle data type negotiation expected message 2, got %d\", msg)\n\t}\n\tif runtimeCaps[1] == 1 {\n\t\tif _, err = s.getBytes(11); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif compileCaps[37]&2 == 2 {\n\t\t\tif _, err = s.getInt(4, false, true); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tlevel := 0\n\tfor {\n\t\tvar n int\n\t\tif compileCaps[27] == 0 {\n\t\t\tn, err = s.getInt(1, false, false)\n\t\t} else {\n\t\t\tn, err = s.getInt(2, false, true)","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/oracle_raw.go#L1103-L1139","documentation":"In the second phase of the raw protocol handshake, the library expects the server's data type negotiation (dty) message with message type 2. A different message byte was received, so the handshake aborts with the actual value. This indicates the server or intermediary deviated from the expected TNS message sequence.","triggerScenarios":"The data-type negotiation step of the connect sequence reads a message byte that is not 2 — e.g. the server sent an error/redirect/refuse packet (type 4/9/11) instead of proceeding to dty negotiation.","commonSituations":"Server refuses the connection (wrong credentials, DB not open) and sends an error message where dty was expected; listener redirect responses; protocol version mismatch between client's negotiated version (4/5/6) and what the server then sends.","solutions":["Read the actual server message — often an ORA- error about login/DB state; fix the underlying login problem (credentials, account locked, database not open).","Verify listener redirects aren't rewriting the stream; connect to the node the listener would redirect to.","Capture TNS traffic and compare the message sequence against the library's expectations; report a server-version incompatibility if it's a consistent order difference."],"exampleFix":"// Diagnostic: log server-side ORA error before dty stage\n// before: handshake fails with 'expected message 2, got 4'\n// after: check alert.log / listener.log for ORA- errors at connect time and fix e.g. locked account:\n//   ALTER USER app_user ACCOUNT UNLOCK;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := connect(); err != nil {\n    if strings.Contains(err.Error(), \"expected message 2\") {\n        // server refused/redirected mid-handshake: check credentials and listener.log\n    }\n}","preventionTips":["Keep credentials valid and accounts unlocked to avoid error-packet responses mid-handshake","Watch listener.log for refusals during deploy windows","Use supported Oracle protocol versions (client negotiates 4/5/6)"],"tags":["oracle","protocol","handshake","negotiation"],"backgroundTag":"unexpected-response-shape","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}