eclipse-vertx/vert.x · warning · IndexOutOfBoundsException
Invalid tag index ${index}
Error message
Invalid tag index ${index} What it means
TagExtractor.name(T,int) is a default interface method that throws IndexOutOfBoundsException when a tag name is requested at an index the extractor does not support. Concrete extractors override it to return tag names for valid indices; the default is a stub signaling out-of-range access. It is reached when iterating code (extractTo, addTags, addressOf) asks for more tags than the extractor provides.
Source
Thrown at vertx-core/src/main/java/io/vertx/core/spi/tracing/TagExtractor.java:50
/**
* Returns the number of tags {@code obj} exposes.
*
* @param obj the object to evaluate
* @return the number of tags
*/
default int len(T obj) {
return 0;
}
/**
* Returns the name of the tag extracted from {@code obj}at the specified {@code index}.
*
* @param obj the object to extract the tag name from
* @param index the index of the tag
* @return the tag name
*/
default String name(T obj, int index) {
throw new IndexOutOfBoundsException("Invalid tag index " + index);
}
/**
* Returns the value of the tag extracted from {@code obj} at the specified {@code index}.
*
* @param obj the object to extract the tag name from
* @param index the index of the tag
* @return the tag value
*/
default String value(T obj, int index) {
throw new IndexOutOfBoundsException("Invalid tag index " + index);
}
/**
* Extract all the tags from {@code obj} into a {@code Map<String, String>}.
*
* @param obj the object to extract the tags from
* @return the map of all tags extracted from the objectView on GitHub (pinned to fb308bd8c3)
Solutions
- Override name(T obj, int index) in your TagExtractor to return a valid tag name for every index in [0, size()) and keep it consistent with size().
- Fix the caller's loop bound so it never asks for index >= size().
- Use one of the provided TagExtractor factories (e.g. TagExtractor.empty() or fromMap-style helpers) instead of the bare default methods.
Example fix
// before
TagExtractor<Req> ex = new TagExtractor<>() { public int size(Req r){return 1;} };
ex.name(req, 0); // IndexOutOfBoundsException
// after
TagExtractor<Req> ex = new TagExtractor<>() {
public int size(Req r){return 1;}
public String name(Req r, int i){ return "req.name"; }
}; Defensive patterns
Strategy: type-guard
Validate before calling
for (int i = 0; i < extractor.size(obj); i++) { String n = extractor.name(obj, i); } Type guard
String safeName(TagExtractor<T> ex, T obj, int i) { return (i >= 0 && i < ex.size(obj)) ? ex.name(obj, i) : null; } Try / catch
try { return extractor.name(obj, index); } catch (IndexOutOfBoundsException e) { return null; } Prevention
- Always implement name(), value(), and size() together in custom TagExtractors
- Derive loop bounds from extractor.size(obj), not hardcoded counts
- Add a test iterating all indices of your extractor
When it happens
Trigger: Calling name(obj, index) with an index >= the number of tags the extractor supports, typically from extractTo/addTags/addressOf when their loop bounds disagree with the overridden name()/size() implementation, or calling the default extractor directly with a non-zero index.
Common situations: Writing a custom TagExtractor that overrides size() but not name()/value() consistently; iteration logic using a wrong tag count; calling the base TagExtractor interface without an overriding implementation.
AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06).
Data as JSON: /api/errors/0e78bb3b72be50e4.
Report an issue: GitHub.