Flink: reading `$files` with vended credentials fails on TaskManagers because split JSON drops the credentials

Đang mở
#18,934 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@ig-suyas đang làm issue này rồi.

Từ ngày 14/11/2026.

  • #19101 của @Ankitkj1999 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
gcp, java

Hướng nghiên cứu

Start with core/src/main/java/org/apache/iceberg/io/FileIOParser.java, where the FileIO is serialized to JSON and rebuilt without its credentials, then look at GCSFileIO.credentials() in the gcp module. The payload's unit test, which round-trips a ManifestReadTask through ScanTaskParser.fromJson and checks the credentials, is the reproduction to run. Done means the credentials survive the JSON round trip for metadata-table tasks, and that test passes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Apache Iceberg version

1.12.0 (latest release)

Query engine

Flink

Please describe the bug 🐞

What happens. We use a REST catalog that vends storage credentials (BigLake on GCS), and the job's own service
account has no direct bucket access. In that setup, a Flink batch query on a metadata table fails, for example
SELECT * FROM t$files. The JobManager plans the scan fine. Every TaskManager then fails reading the manifests with
403 storage.objects.get, and the error names the job's own service account. A normal data scan of the same table
works.

Why. The FLIP-27 source sends each split to the TaskManagers as JSON. For metadata-table tasks, that JSON
includes the FileIO, written by FileIOParser. FileIOParser writes only io.properties()
(L47)
and rebuilds the FileIO without credentials
(L79).
GCSFileIO keeps vended credentials in a separate field, not in properties()
(L85).
So on the TaskManager the rebuilt FileIO has no credentials and falls back to the environment's identity.

Data scans aren't affected, because their reader's FileIO travels by Java serialization, which keeps the credentials.
$entries and $all_manifests use the same parser, so they are probably affected too. S3FileIO stores
credentials the same way
(L114),
but we've only tested GCS. Related: #10735 added this JSON path, and #10926 fixed a similar gap in the same parser.

Repro (unit test, no cloud needed). The test builds a $files task whose GCSFileIO holds one credential, then
round-trips it through ScanTaskParser. The credentials come back empty on 1.11.0 and 1.12.0. The same task
round-tripped through Java serialization keeps them.

Test
package org.apache.iceberg;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.File;                                                                                                    import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;                                                                                                   import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.gcp.gcs.GCSFileIO;
import org.apache.iceberg.io.StorageCredential;                                                                         import org.apache.iceberg.types.Types;
import org.junit.jupiter.api.Test;                                                                                      import org.junit.jupiter.api.io.TempDir;

public class TestFilesTaskCredentials {
  @Test                                                                                                                   public void splitJsonKeepsVendedCredentials(@TempDir File dir) throws Exception {
    PartitionSpec spec = PartitionSpec.unpartitioned();                                                                     ManifestWriter<DataFile> writer =
        ManifestFiles.write(2, spec, Files.localOutput(new File(dir, "m.avro")), 1L);
    writer.add(DataFiles.builder(spec).withPath("gs://bucket/t/data/a.parquet")                                                 .withFormat(FileFormat.PARQUET).withFileSizeInBytes(10).withRecordCount(1).build());
    writer.close();

                                                                                                         StorageCredential cred = StorageCredential.create("gs://bucket/",
        Map.of("gcs.oauth2.token", "vended-token", "gcs.oauth2.token-expires-at", "4102444800000"));                        GCSFileIO io = new GCSFileIO();
    io.initialize(Map.of("gcs.project-id", "p"));
    io.setCredentials(List.of(cred));

    Schema data = new Schema(Types.NestedField.required(1, "x", Types.LongType.get()));
    Schema projection = new Schema(DataFile.getType(Types.StructType.of()).fields());
    FileScanTask task = new BaseFilesTable.ManifestReadTask(
        data, io, Map.of(0, spec), writer.toManifestFile(), projection, Expressions.alwaysTrue());

    FileScanTask after = ScanTaskParser.fromJson(ScanTaskParser.toJson(task), true);

    Field f = BaseFilesTable.ManifestReadTask.class.getDeclaredField("io");
    f.setAccessible(true);
    assertEquals(List.of(cred), ((GCSFileIO) f.get(after)).credentials()); // fails: []
  }
}

Possible fix. When the FileIO implements SupportsStorageCredentials, have FileIOParser write credentials() to
the JSON and pass them back to the 4-argument CatalogUtil.loadFileIO when reading.

Workaround. SET 'table.exec.iceberg.use-flip27-source' = 'false'; The legacy source Java-serializes its splits, so
the credentials survive. That fixed it for us on the same cluster and table. The legacy source is deprecated, though.

Willingness to contribute
  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
Ngôn ngữ chính
Java
Star
9.4k
Fork
3.7k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
169

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/iceberg

Tất cả issue của apache/iceberg

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.