{"record":{"id":"ee9597b9f825c03a","repo":"apache/hadoop","slug":"s-doesn-t-support-getobjecttagging","errorCode":null,"errorMessage":"%s doesn't support getObjectTagging.","messagePattern":"(.+?) doesn't support getObjectTagging\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/ObjectStorage.java","lineNumber":336,"sourceCode":"   *\n   * @param key     the key of the object key.\n   * @param newTags the new tags to put.\n   * @throws RuntimeException if key doesn't exist.\n   */\n  default void putTags(String key, Map<String, String> newTags) {\n    throw new UnsupportedOperationException(\n        this.getClass().getSimpleName() + \" doesn't support putObjectTagging.\");\n  }\n\n  /**\n   * Get all attached tags of the object.\n   *\n   * @param key the key of the object.\n   * @return map containing all tags.\n   * @throws RuntimeException if key doesn't exist.\n   */\n  default Map<String, String> getTags(String key) {\n    throw new UnsupportedOperationException(\n        this.getClass().getSimpleName() + \" doesn't support getObjectTagging.\");\n  }\n\n  /**\n   * Gets the object status for the given key.\n   * It's different from {@link ObjectStorage#head(String)}, it returns object info if the key\n   * exists or the prefix with value key exists.\n   * <p>\n   * There are three kinds of implementations:\n   * <ul>\n   *   <li>Uses the headObject API if the object storage support directory bucket and the requested\n   *   bucket is a directory bucket, the object storage will return object directly if the file or\n   *   dir exists, otherwise return null</li>\n   *   <li>Uses getFileStatus API if the object storage support it, e.g. TOS. The object storage\n   *   will return the object directly if the key or prefix exists, otherwise return null.</li>\n   *   <li>If the object storage doesn't support above all cases, you have to try to headObject(key)\n   *   at first, if the object doesn't exist, and then headObject(key + \"/\") later if the key\n   *   doesn't end with '/', and if neither the new key doesn't exist, and then use listObjects API","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-tos/src/main/java/org/apache/hadoop/fs/tosfs/object/ObjectStorage.java#L318-L354","documentation":"ObjectStorage.getTags has a default implementation that throws UnsupportedOperationException(\"<ClassName> doesn't support getObjectTagging.\"). Only the real TOS backend overrides it (TOS.getTags), so reading tags from the local FileStore backend or a custom implementation without an override fails with this error.","triggerScenarios":"Calling ObjectStorage.getTags(key) on a FileStore instance or a custom ObjectStorage plugin that did not override the default method, typically while porting tag-reading logic from the TOS backend to another backend.","commonSituations":"Tests running against the file-based backend; custom storage plugins that never implement tagging; code assuming every ObjectStorage supports object tagging.","solutions":["Use the real TOS object storage when tag reads are required","Guard with a capability check (instanceof TOS or a supportsTags flag) before calling getTags","Override getTags in custom ObjectStorage implementations where the backend supports it","Degrade gracefully: skip tagging features when unsupported instead of failing"],"exampleFix":"// before\nMap<String, String> tags = storage.getTags(key);\n\n// after\nMap<String, String> tags = (storage instanceof TOS)\n    ? storage.getTags(key)\n    : Collections.emptyMap();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"private static boolean supportsTagging(ObjectStorage storage) {\n  return storage instanceof org.apache.hadoop.fs.tosfs.object.tos.TOS;\n}","tryCatchPattern":"try {\n  Map<String, String> tags = storage.getTags(key);\n} catch (UnsupportedOperationException e) {\n  // backend without tagging support: degrade to empty tags\n  return Collections.emptyMap();\n}","preventionTips":["Check instanceof TOS before reading tags","Default to empty tags when the backend lacks support","Document tagging capability requirements in deployment docs"],"tags":["hadoop-tos","object-storage","object-tagging","unsupported-operation","spi"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}