arXiv:2608.29290cs.IRAug 2026

Manuscript Offprint

arXiv:2608.29290

Database-Augmented RAG for Automated Repair of REST API Misuses

Shoei Inoue, Norihiro Yoshida, Erina Makihara, Shiyu Yang, Katsuro Inoue

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Shoei Inoue 1^{1}, Norihiro Yoshida 1^{1}[0000-0003-4910-1729], Erina Makihara 1^{1}[0009-0008-8777-619X], Shiyu Yang 1^{1}[0009-0005-0955-3431], and Katsuro Inoue 1^{1}[0000-0001-5424-0614]

Ritsumeikan University, Osaka, Japan

is0604fp@ed.ritsumei.ac.jp, norihiro@fc.ritsumei.ac.jp,

makihara@fc.ritsumei.ac.jp, yangsy@fc.ritsumei.ac.jp,

inoue-k@fc.ritsumei.ac.jp

Abstract. Many Internet of Things (IoT) services provide Representational State Transfer (REST) APIs, which require client developers to implement applications that conform to the corresponding API specifications. When client programs contain API misuse, developers debug them based on error responses. However, such responses are often insufficient for identifying the root cause, requiring developers to repeatedly communicate with the server. Retrieval-Augmented Generation (RAG) is a promising approach for providing large language models (LLMs) with external knowledge. However, in automated repair of REST API misuses, it remains unclear how specifications should be stored in a RAG database. This study evaluates how different configurations for organizing API specifications affect RAG-based repair of REST API misuse. We constructed 11 RAG configurations with different database structures and compared their repair rates with a baseline method. For evaluation, we used REST API misuse cases collected from real-world repositories. The results show that, in the studied datasets, the baseline method achieved a repair rate of 54.3%, whereas a RAG-based method using four databases achieved a maximum repair rate of 88.6%. These results indicate that organizing specifications according to version and content type can be an effective design choice for RAG-based REST API misuse repair.

Keywords: Automated Program Repair · LLM · RAG

1 Introduction

In recent years, Internet of Things (IoT) devices have become increasingly widespread [30][30] [33][33]. APIs play a fundamental role in enabling interoperability and scalability, as they rely on continuous communication between heterogeneous devices and cloud or edge services [30][30]. Consequently, API-based development approaches have attracted growing attention.

Client development for IoT devices requires consideration of factors such as limited computational resources, diverse network protocols, and heterogeneous

Inoue et al.

entity integration [30]. Consequently, IoT systems are more complex than traditional systems, rendering them more prone to errors during development [14]. In practice, client implementations must bridge device-specific capabilities, unstable edge networks, and frequent vendor-side specification changes [22] [41]. A considerable portion of these errors remains unresolved, negatively affecting system reliability and maintainability.

Most IoT services provide Representational State Transfer (REST) APIs [9], enabling developers to access resources efficiently.

Developers must follow the REST API specifications when implementing client code. Generally, they send HTTP requests and examine the corresponding responses to verify code correctness. However, error messages and status codes provide limited diagnostic information and do not indicate the root cause of a failure. Consequently, developers must repeatedly send requests and check responses to identify and resolve defects in client code. This ambiguity creates trial-and-error debugging cycles, which increase development time and raise the risk of shipping incomplete fixes.

When providers update a REST API specification, developers must update their client code accordingly. However, in practice, such updates are often neglected, potentially introducing various defects and vulnerabilities [3][3] [14][14] [22][22] [41][41]. Therefore, developers must promptly update their code to align with the latest REST API specification.

Previous studies explored API misuse detection for Java APIs [1] [24] [32], as well as automated bug fixing using large language models (LLMs) [7] [16] [39] [42]. These studies focused on method-call misuse in Java. However, REST API calls differ significantly from Java API calls. Java APIs need correct method calls. In contrast, REST APIs need correct endpoints, request headers, and request bodies. Moreover, REST API misuse is often associated with provider-side policy changes, such as authentication updates and version-specific revisions. Therefore, effective repair requires up-to-date external specification context, rather than relying only on local code semantics.

To address this problem, we adopt Retrieval-Augmented Generation (RAG) [23], which can add domain-specific information and repair details to the prompt, rendering it a promising approach to mitigate these challenges [35]. In this study, we propose a Database-Augmented RAG approach to the automated repair of REST API client programs. We compare its performance with that of the baseline method.

We collected misuse cases from SwitchBot and Fitbit, both of which provide REST APIs for IoT services. Subsequently, we applied our method to these cases and evaluated 11 RAG database configurations. Specifically, we designed various data storage strategies, such as storing the latest and deprecated specifications in separate databases, as well as separating code snippets and natural-language text.

The contributions of this study are as follows:

– We evaluated 11 distinct database configurations for RAG and compared their effectiveness for repairing REST API misuse in the studied dataset.

Table 1: The SwitchBot API specification 1^{1}

ParameterType Location Required
AuthorizationStringheaderYes
signStringheaderYes
tLongheaderYes
nonceLongheaderYes

– We demonstrate that separating retrieval contexts by API version and content type can improve repair performance in the studied dataset.

The remainder of this paper is organized as follows. Section 2 describes key terminology and provides background information. Section 3 explains the investigation method, dataset, and evaluation metrics. Section 4 presents the experimental results. Section 5 discusses related work, and Section 6 concludes the paper with a summary and future directions.

References (39)