# Stale data bug in synthetic source loader on text fields

**URL:** <https://discuss.elastic.co/t/stale-data-bug-in-synthetic-source-loader-on-text-fields/374634>\
**Category:** Elasticsearch\
**Created:** [February 17, 2025, 2:29pm UTC](https://discuss.elastic.co/t/stale-data-bug-in-synthetic-source-loader-on-text-fields/374634 "2025-02-17T14:29:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffgan96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeffgan96/32/141426_2.png) [@jeffgan96](https://discuss.elastic.co/u/jeffgan96)\
**Post date:** [February 17, 2025, 2:29pm UTC](https://discuss.elastic.co/t/stale-data-bug-in-synthetic-source-loader-on-text-fields/374634/1 "2025-02-17T14:29:27Z")

</div>

[#112173](https://github.com/elastic/elasticsearch/pull/112173) fixed an issue in synthetic source loader where stale data got loaded .

this got reworked in [#112480](https://github.com/elastic/elasticsearch/pull/112480) but unfortunately looks like a bug got introduced where we dont reset values if values.size() is 1 .

needed some clarification on whether we can confirm this as a bug before raising an bug tracker for this

server/src/main/java/org/elasticsearch/index/mapper/StringStoredFieldFieldLoader.java

```auto
    public final void write(XContentBuilder b) throws IOException {
        switch (values.size()) {
            case 0:
                return;
            case 1:
                b.field(simpleName);
                write(b, values.get(0));
                return;
            default:
                b.startArray(simpleName);
                for (Object value : values) {
                    write(b, value);
                }
                b.endArray();
        }
        reset();
    }
```
