Table of Contents
Fetching ...

Automated Program Repair Based on REST API Specifications Using Large Language Models

Katsuki Yamagishi, Norihiro Yoshida, Erina Makihara, Katsuro Inoue

TL;DR

The paper addresses the problem of REST API client misuses that are hard to diagnose from server responses alone. It presents dcFix, a hybrid method that first performs static and data-flow analysis to detect deviations from API specifications, then crafts targeted prompts containing both the detected deviations and the unsatisfied specifications for an LLM to generate compliant fixes. Empirical results on SwitchBot and Philips Hue APIs show that dcFix achieves higher repair success than prompts that omit specification details and detects a large portion of deviation points. The work significantly reduces debugging effort for REST API clients and suggests future directions like retrieval-augmented generation to maintain up-to-date specifications in prompts.

Abstract

Many cloud services provide REST API accessible to client applications. However, developers often identify specification violations only during testing, as error messages typically lack the detail necessary for effective diagnosis. Consequently, debugging requires trial and error. This study proposes dcFix, a method for detecting and automatically repairing REST API misuses in client programs. In particular, dcFix identifies non-conforming code fragments, integrates them with the relevant API specifications into prompts, and leverages a Large Language Model (LLM) to produce the corrected code. Our evaluation demonstrates that dcFix accurately detects misuse and outperforms the baseline approach, in which prompts to the LLM omit any indication of code fragments non conforming to REST API specifications.

Automated Program Repair Based on REST API Specifications Using Large Language Models

TL;DR

The paper addresses the problem of REST API client misuses that are hard to diagnose from server responses alone. It presents dcFix, a hybrid method that first performs static and data-flow analysis to detect deviations from API specifications, then crafts targeted prompts containing both the detected deviations and the unsatisfied specifications for an LLM to generate compliant fixes. Empirical results on SwitchBot and Philips Hue APIs show that dcFix achieves higher repair success than prompts that omit specification details and detects a large portion of deviation points. The work significantly reduces debugging effort for REST API clients and suggests future directions like retrieval-augmented generation to maintain up-to-date specifications in prompts.

Abstract

Many cloud services provide REST API accessible to client applications. However, developers often identify specification violations only during testing, as error messages typically lack the detail necessary for effective diagnosis. Consequently, debugging requires trial and error. This study proposes dcFix, a method for detecting and automatically repairing REST API misuses in client programs. In particular, dcFix identifies non-conforming code fragments, integrates them with the relevant API specifications into prompts, and leverages a Large Language Model (LLM) to produce the corrected code. Our evaluation demonstrates that dcFix accurately detects misuse and outperforms the baseline approach, in which prompts to the LLM omit any indication of code fragments non conforming to REST API specifications.

Paper Structure

This paper contains 10 sections, 2 figures, 3 tables.

Figures (2)

  • Figure 1: An Overview of dcFix
  • Figure 2: Matching between a deviation point (left) and its corresponding unsatisfied specification (right)