bug: InMemoryCatalog skips the namespace existence check in CreateTable and RegisterTable
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
Piste de recherche
Commencez dans src/iceberg/catalog/memory/in_memory_catalog.cc et examinez CreateTable et RegisterTable, puis comparez la gestion des namespaces avec SqlCatalog::CreateTable. Le travail est terminé lorsque les namespaces manquants sont rejetés avec kNoSuchNamespace avant l’écriture des métadonnées, sans modifier le comportement de double enregistrement hors périmètre.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
InMemoryCatalog fails to validate that a table's namespace exists before acting, in two methods.
CreateTable writes the table metadata file through FileIO before it checks the namespace. Creating a table under a namespace that does not exist returns kNoSuchNamespace, but on an object-store FileIO the call first writes an orphaned 00000-<uuid>.metadata.json that nothing ever removes (DropTable's purge only touches registered tables). On the default local FileIO the stray write fails first, so the caller gets a misleading kIOError instead of kNoSuchNamespace.
RegisterTable guards with if (!root_namespace_->NamespaceExists(identifier.ns)). NamespaceExists returns Result<bool> (std::expected<bool, Error>); !result tests has_value(), not the contained bool, and a missing namespace is reported as a value false, never an error. The guard therefore never fires, so registering under a missing namespace falls through and surfaces as kUnknownError ("The registry failed.") instead of kNoSuchNamespace.
Root Cause
CreateTable (src/iceberg/catalog/memory/in_memory_catalog.cc): the namespace is only enforced inside UpdateTableMetadataLocation, which runs after TableMetadataUtil::Write has already persisted the file. TableExists(identifier).value_or(false) ahead of the write swallows the kNoSuchNamespace from the namespace lookup and reports "table absent", so control falls through to the write.
RegisterTable: if (!root_namespace_->NamespaceExists(identifier.ns)) reads as if (!result.has_value()). NamespaceExists maps a missing namespace to Ok(false), so the branch is dead code; the error later comes out of the inner RegisterTable and is rewritten to kUnknownError.
Impact
CreateTable leaks an orphan metadata file on object-store FileIO and returns the wrong error kind (kIOError) on local FileIO. InMemoryCatalog is documented as not for production use (unit tests, prototyping, demonstration), so this is a correctness and robustness issue, not a security one.
RegisterTable returns kUnknownError for a missing namespace instead of kNoSuchNamespace. SqlCatalog::RegisterTable and the REST error handler both return kNoSuchNamespace, so InMemoryCatalog is the outlier here.
Proposed Fix
Unwrap NamespaceExists and return kNoSuchNamespace before any metadata write, in both methods, mirroring SqlCatalog::CreateTable.
Out of scope
RegisterTablestill maskskAlreadyExistsaskUnknownErroron the duplicate-registration path (if (!root_namespace_->RegisterTable(...))); the clean fix isICEBERG_RETURN_UNEXPECTED(...), asRenameTablealready does. Follow-up.StageCreateTableandUpdateTable's create branch share the same write-before-validate pattern. Follow-up.
- Langage dominant
- C++
- Étoiles
- 228
- Forks
- 136
- Merge moyen
- 5 j 22 h
- PR mergées (30 j)
- 52
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/iceberg-cpp
-
bug: TableMetadataBuilder::RemoveSchemas leaves removed ids in the schema indexPeut-être pris @LuciferYang l’a pris il y a 2 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
apache/iceberg-cpp#1011 ·
Les mainteneurs répondent en général sous 2 jours
-
build: regression after #1021 — Arrow's arrow_SOURCE_DIR collides with FetchContent on CMake 3.28, breaks vendored Arrow buildPeut-être pris @raulcd l’a pris aujourd’hui. Ouverte
Difficulté 3/5 Une demi-journée Accessibilité débutants 22/100
apache/iceberg-cpp#1028 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 12/100
apache/iceberg-cpp#1027 ·
Les mainteneurs répondent en général sous 2 jours
-
bug: gzip table metadata is neither written nor detected as gzipPeut-être pris @LuciferYang l’a pris il y a 2 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 66/100
apache/iceberg-cpp#1013 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
apache/iceberg-cpp#1000 · 2 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de apache/iceberg-cpp
Issues similaires
-
accessibility good first issue hacktoberfest help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
OpenChemistry/avogadrolibs#3184 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Tracktion/tracktion_engine#475 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
redis/memtier_benchmark#732 ·
Les mainteneurs répondent en général sous 1 jour
-
binding:web core docs p3
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
RunanywhereAI/runanywhere-sdks#1123 ·
Les mainteneurs répondent en général sous 1 jour
-
ai_p3 comp-data-types
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
ClickHouse/ClickHouse#126316 ·
Les mainteneurs répondent en général sous 1 jour