{"record":{"id":"a87d52f0026dc5ff","repo":"apache/seatunnel","slug":"seek-not-supported","errorCode":null,"errorMessage":"Seek not supported","messagePattern":"Seek not supported","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPInputStream.java","lineNumber":67,"sourceCode":"\n        if (stream == null) {\n            throw new IllegalArgumentException(E_NULL_INPUT_STREAM);\n        }\n        if (channel == null || !channel.isConnected()) {\n            throw new IllegalArgumentException(E_CLIENT_NULL);\n        }\n        this.wrappedStream = stream;\n        this.channel = channel;\n        this.connectionPool = connectionPool;\n        this.stats = stats;\n\n        this.pos = 0;\n        this.closed = false;\n    }\n\n    @Override\n    public void seek(long position) throws IOException {\n        throw new IOException(E_SEEK_NOT_SUPPORTED);\n    }\n\n    @Override\n    public boolean seekToNewSource(long targetPos) throws IOException {\n        throw new IOException(E_SEEK_NOT_SUPPORTED);\n    }\n\n    @Override\n    public long getPos() throws IOException {\n        return pos;\n    }\n\n    @Override\n    public synchronized int read() throws IOException {\n        if (closed) {\n            throw new IOException(E_STREAM_CLOSED);\n        }\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-sftp/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sftp/system/SFTPInputStream.java#L49-L85","documentation":"SFTPInputStream.seek() is not implemented: this stream is a sequential SFTP read and cannot jump to an arbitrary position. Any seek call throws IOException with 'Seek not supported'. seekToNewSource behaves the same way.","triggerScenarios":"Calling seek(pos) on an SFTPInputStream, typically when a framework (e.g. a reader doing split re-processing, checkpoint restore, or random-access reads) assumes a seekable stream.","commonSituations":"Recovering a failed read by seeking back to a saved offset; using a reader that requires Seekable input against an SFTP source; framework retry logic that repositions streams mid-file.","solutions":["Re-open the SFTPInputStream and skip(pos) to the desired offset instead of seeking.","Wrap or choose a source/stream implementation that supports seek if random access is required.","Restructure the consumer to read sequentially without repositioning (buffer data if needed).","If using a framework with a 'seekable/seek' option, disable it for SFTP sources."],"exampleFix":"// before\nin.seek(checkpointOffset); // throws\n// after\nin.close();\nin = SFTPInputStream.getInstance(path, ...);\nIOUtils.skipFully(in, checkpointOffset);","handlingStrategy":"fallback","validationCode":"// No validation possible; SFTPInputStream never supports seek — avoid seekable consumers","typeGuard":"boolean supportsSeek(InputStream in) { return !(in instanceof SFTPInputStream); }","tryCatchPattern":"try { in.seek(pos); }\ncatch (IOException e) {\n    if (\"Seek not supported\".equals(e.getMessage())) { reopenAndSkip(in, pos); }\n    else throw e;\n}","preventionTips":["Design readers to consume SFTP streams sequentially","On resume, re-open the stream and skip to the saved offset","Do not configure seekable/random-access readers for SFTP sources"],"tags":["sftp","inputstream","seek","unsupported-operation"],"backgroundTag":"operation-not-supported","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}