arrow
Return

Identifying and Mitigating API Misuse in Large Language Models

delete2026-03-01
delete0
PRE
AI
T
Terry Yue Zhuo
J
Junda He
J
Jiamou Sun
Z
Zhenchang Xing
D
David Lo
J
John Grundy
DOI:10.1109/TSE.2026.3651566delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
API misuse in code generated by large language models (LLMs) presents a serious and growing challenge in software development. While LLMs demonstrate impressive code generation capabilities, their interactions with complex library APIs are often error-prone, potentially leading to software failures and vulnerabilities. In this paper, we conduct a large-scale study of API misuse patterns in LLM-generated code, analyzing both method selection and parameter usage across Python and Java, using three representative LLMs (StarCoder-7B, Qwen2.5-Coder-7B, and GitHub Copilot). Based on extensive manual annotation of 3,209 method-level and 3,492 parameter-level misuses, we identify and categorize four recurring misuse types by building on and refining prior API misuse taxonomies. Our evaluation of three widely used LLMs, StarCoder-7B, Qwen2.5-Coder-7B, and GitHub Copilot, reveals persistent challenges in API usage, particularly hallucination and intent misalignment. To address these issues, we propose Dr.Fix, an LLM-based automatic repair approach guided by our taxonomy. Dr.Fix improves repair accuracy compared to baseline prompting and existing repair methods, with gains of up to 38.4 BLEU and 40% in exact match on benchmark datasets. This work offers important insights into the current limitations of LLMs in API usage and provides insights into current limitations and points to directions for improving automated misuse repair in code generation systems.
Keywords:
Codes
Taxonomy
Libraries
Maintenance engineering
Java
Software development management
Python
Large language models
Programming
Manuals
Code generation
large language model
API misuse
automatic program repair
empirical software engineering

Journal

IEEE Transactions on Software Engineering cover
IEEE Transactions on Software Engineering
IF:
5.6
Papers:
2.9K
Citations:
1.1W

Organization

C
CSIRO Data61
Scholars:
54
Papers: 39
Citations: 0
M
monash university
Scholars:
9.1K
Papers: 4.1K
Citations: 0
S
singapore management university
Scholars:
371
Papers: 278
Citations: 0
researcher View more organizations
Cited Papers

Cited Papers

BLEU
err2001-01-01
err0
errOAAI
errKishore Papineni; Salim Roukos; Todd Ward; Wei-Jing Zhu
errShare
errSave
Automating code review activities by large-scale pre-training
err2022-11-09
err0
errOAAI
errZhiyu Li; Shuai Lu; Daya Guo; Nan Duan; Shailesh Jannu; Grant Jenks; Deep Majumder; Jared Green; Alexey Svyatkovskiy; Shengyu Fu; Neel Sundaresan
errShare
errSave
NLP Evaluation in trouble: On the Need to Measure LLM Data Contamination for each Benchmark
err2023-01-01
err0
errOAAI
errOscar Sainz; Jon Campos; Iker García-Ferrero; Julen Etxaniz; Oier Lopez de Lacalle; Eneko Agirre
errShare
errSave
Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issues
err2024-06-04
err8
errOAAI
errLiu, Yue; Le-Cong, Thanh; Widyasari, Ratnadira; Tantithamthavorn, Chakkrit; Li, Li; Le, Xuan-Bach D.; Lo, David
errShare
errSave
SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair
err2021-01-01
err217
errOAAI
errChen, Zimin; Kommrusch, Steve; Tufano, Michele; Pouchet, Louis-Noel; Poshyvanyk, Denys; Monperrus, Martin
errShare
errSave
researcher View more