Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error gives inaccurate and incomplete list of valid values when bad index.codec setting is provided #17561

Open
peterskim12 opened this issue Mar 10, 2025 · 1 comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@peterskim12
Copy link

Describe the bug

When I try creating an index and pass in an invalid index.codec setting, the error returns:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "unknown value for [index.codec] must be one of [default, lz4, best_compression, zlib] but was: zstd_no_dic"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "unknown value for [index.codec] must be one of [default, lz4, best_compression, zlib] but was: zstd_no_dic"
  },
  "status": 400
}

According to the documentation, this is not the list of valid values accepted by the API in the latest version. https://opensearch.org/docs/2.17/install-and-configure/configuring-opensearch/index-settings/#static-index-level-index-settings

It should be:

  • default
  • best_compression
  • zstd
  • zstd_no_dict
  • qat_lz4 (on supported systems)
  • qat_deflate (on supported systems)

I tried creating an index using index.codec = lz4 and zlib and they worked, even though the documentation does not state they are valid values. Regardless, I think the error message should be updated to match the documentation.

Related component

Indexing

To Reproduce

PUT test
{
  "settings": {
    "index.codec": "invalid_codec"
  }
}

Expected behavior

Return error with valid index.codec options:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "unknown value for [index.codec] must be one of [default, best_compression, zstd, zstd_no_dict, qat_lz4, qat_deflate] but was: invalid_codec"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "unknown value for [index.codec] must be one of [default, best_compression, zstd, zstd_no_dict, qat_lz4, qat_deflate] but was: invalid_codec"
  },
  "status": 400
}

Additional Details

Host/Environment (please complete the following information):

  • OS: macos Docker
  • Version 2.19

same behavior on Fedora 39, version 2.17.1

Additional context

I can submit a PR, but I'm just following the contributing guide which says I should file an issue first. Thanks!

@peterskim12 peterskim12 added bug Something isn't working untriaged labels Mar 10, 2025
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Mar 10, 2025
@peterskim12 peterskim12 changed the title [BUG] Error returned when bad index.codec setting is provided gives inaccurate and incomplete list of valid values [BUG] Error gives inaccurate and incomplete list of valid values when bad index.codec setting is provided Mar 10, 2025
@dbwiddis
Copy link
Member

Interesting. The error message is hardcoded but clearly is incomplete as it should include "lucene_default" as well as everything in Codec.availableCodecs().

public static final Setting<String> INDEX_CODEC_SETTING = new Setting<>("index.codec", "default", s -> {
switch (s) {
case "default":
case "lz4":
case "best_compression":
case "zlib":
case "lucene_default":
return s;
default:
if (Codec.availableCodecs().contains(s)) {
return s;
}
for (String codecName : Codec.availableCodecs()) {
Codec codec = Codec.forName(codecName);
if (codec instanceof CodecAliases) {
CodecAliases codecWithAlias = (CodecAliases) codec;
if (codecWithAlias.aliases().contains(s)) {
return s;
}
}
}
throw new IllegalArgumentException(
"unknown value for [index.codec] must be one of [default, lz4, best_compression, zlib] but was: " + s
);
}
}, Property.IndexScope, Property.NodeScope);

I can submit a PR, but I'm just following the contributing guide which says I should file an issue first. Thanks!

Looking forward to the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
None yet
Development

No branches or pull requests

2 participants