{"record":{"id":"941b11924083238f","repo":"apache/hadoop","slug":"s-doesn-t-support-putobjecttagging","errorCode":null,"errorMessage":"%s doesn't support putObjectTagging.","messagePattern":"(.+?) doesn't support putObjectTagging\\.","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":324,"sourceCode":"   * Will overwrite dest object if dest object exists.\n   *\n   * @param srcKey source object key\n   * @param dstKey dest object key\n   * @throws RuntimeException if rename failed，e.g. srcKey is equal to dstKey or the source object\n   *                          doesn't exist.\n   */\n  void rename(String srcKey, String dstKey);\n\n  /**\n   * Attach tags to specified object. This method will overwrite all existed tags with the new tags.\n   * Remove all existed tags if the new tags are empty. The maximum tags number is 10.\n   *\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","sourceCodeStart":306,"sourceCodeEnd":342,"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#L306-L342","documentation":"ObjectStorage is the storage SPI of hadoop-tos. putTags has a default implementation that throws UnsupportedOperationException(\"<ClassName> doesn't support putObjectTagging.\"). Only the real TOS backend overrides it (TOS.putTags), so calling putTags on the local FileStore backend or on any custom ObjectStorage implementation that did not override the default fails with this error.","triggerScenarios":"Calling ObjectStorage.putTags(key, tags) on a FileStore instance (local/test backend) or on a custom ObjectStorage plugin that lacks an override, e.g. while exercising tagging logic in unit tests or against a file-based store.","commonSituations":"Running connector tests on the file-based backend that exercise tagging; writing a custom ObjectStorage implementation and forgetting to implement putTags/getTags.","solutions":["Use the real TOS object storage (tos:// URI with bucket credentials) when object tagging is required","Guard the call with a capability check (instanceof TOS, or an explicit supportsTags flag) before invoking putTags","Override putTags/getTags in custom ObjectStorage implementations if the backing store supports tagging"],"exampleFix":"// before\nstorage.putTags(key, tags);\n\n// after\nif (storage instanceof TOS) {\n  storage.putTags(key, tags);\n} else {\n  LOG.warn(\"Object tagging unsupported by {}\", storage.getClass().getSimpleName());\n}","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  storage.putTags(key, tags);\n} catch (UnsupportedOperationException e) {\n  LOG.warn(\"Tagging unsupported by {}: {}\", storage.getClass().getSimpleName(), e.getMessage());\n}","preventionTips":["Check instanceof TOS before tagging operations","Do not exercise tagging against the local FileStore backend","Implement putTags/getTags in custom ObjectStorage plugins that need them"],"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"}