Code repairing method, device, equipment and product

By combining static and dynamic repair methods, generative models, and the use of sandbox environments, the problem of low code repair success rate in existing technologies is solved, and efficient code repair is achieved.

CN120677458APending Publication Date: 2025-09-19BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202480005874.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-28
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing dynamic repair methods and static repair methods each have limitations when automatically repairing code, resulting in a low success rate of code repair.

Method used

The static and dynamic repair methods are organically combined, candidate patches are generated through a generative model, and tested in a sandbox environment. The two methods are iteratively used until the code is successfully repaired.

Benefits of technology

It greatly improves the success rate and efficiency of repairing defective codes and improves the work efficiency of the development team.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120677458A_ABST
    Figure CN120677458A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for repairing codes, computing equipment, a computer readable storage medium and a computer program product. The method comprises the steps of determining defect codes in a code bin based on problem description; on the basis of the defect code and the problem description, one repairing method is selected from a static repairing method and a dynamic repairing method to repair the defect code; generating a candidate patch for repairing the defect code based on the selected repairing method; determining whether the generated candidate patch can repair the defect code or not; and in response to determining that the candidate patch cannot repair the defective code, determining to repair the defective code using the other different one of the static repair method and the dynamic repair method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more particularly, to a method, apparatus, computing device, computer-readable storage medium, and computer program product for repairing code. Background Art

[0002] Developers typically use version control and collaboration platforms to host and manage software code. These platforms typically provide components for tracking and managing project tasks, bug reports, feature requests, and more. Users can use natural language to record various issues encountered during software development and use. These tools not only help team members describe and track issues in detail and fix the associated code, but also provide a collaborative platform for developers to discuss resolution strategies and implementation plans.

[0003] However, as projects grow in size and complexity, manually handling issues and fixing code can become tedious and time-consuming. In these situations, automated problem-solving and code-fixing mechanisms become particularly important. These mechanisms can significantly improve developer productivity, freeing them up to focus on more creative and complex tasks. Therefore, developing an effective method for automatically solving issues and fixing code can significantly boost team productivity. Summary of the Invention

[0004] In view of this, the present disclosure provides a method, apparatus, computing device, computer-readable storage medium, and computer program product for automatically repairing code, which can organically combine static repair methods and dynamic repair methods, thereby greatly improving the efficiency and success rate of repairing defective code.

[0005] According to a first aspect of the present disclosure, a method for repairing code is provided, comprising: determining defective code in a code repository based on a problem description; selecting a repair method from a static repair method and a dynamic repair method to repair the defective code based on the defective code and the problem description; generating a candidate patch for repairing the defective code based on the selected repair method; determining whether the generated candidate patch can repair the defective code; and in response to determining that the candidate patch cannot repair the defective code, determining to use another different repair method from the static repair method and the dynamic repair method to repair the defective code.

[0006] According to a second aspect of the present disclosure, there is provided an apparatus for repairing code, comprising: a defect code determination unit configured to determine a defect code in a code bin based on a problem description; a repair method selection unit configured to select a repair method from a static repair method and a dynamic repair method to repair the defect code based on the defect code and the problem description; a candidate patch generation unit configured to generate a candidate patch for repairing the defect code based on the selected repair method; a candidate patch determination unit configured to determine whether the generated candidate patch can repair the defect code; and a repair method switching unit configured to determine to use another different repair method from the static repair method and the dynamic repair method to repair the defect code in response to determining that the candidate patch cannot repair the defect code.

[0007] According to a third aspect of the present disclosure, a computing device is provided, comprising: at least one processing unit; and at least one memory, the at least one memory being coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the computing device to execute the method as described in the first aspect of the present disclosure.

[0008] According to a fourth aspect of the present disclosure, a non-transitory computer storage medium is provided, comprising machine-executable instructions, which, when executed by a device, cause the device to perform the method according to the first aspect of the present disclosure.

[0009] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising machine-executable instructions, which, when executed by a device, cause the device to perform the method according to the first aspect of the present disclosure.

[0010] It should be understood that the summary of the invention is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The above and other objects, features and advantages of the embodiments of the present disclosure will become more readily understood through the following detailed description with reference to the accompanying drawings, in which several embodiments of the present disclosure are illustrated by way of example and not limitation, in which:

[0012] Figure 1 A schematic diagram illustrating an example environment in which embodiments according to the present disclosure may be implemented;

[0013] Figure 2 A flowchart of a method for repairing code according to an embodiment of the present disclosure is shown;

[0014] Figure 3 A schematic structural diagram of a code repair system according to an embodiment of the present disclosure is shown;

[0015] Figure 4 A block diagram showing an apparatus for repairing code according to an embodiment of the present disclosure; and

[0016] Figure 5 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0017] Throughout the drawings, the same or similar reference numbers denote the same or similar elements. DETAILED DESCRIPTION

[0018] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.

[0019] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. can refer to different or the same objects, unless explicitly stated otherwise. Other explicit and implicit definitions may also be included below.

[0020] As mentioned above, automatically resolving code issues can significantly improve development teams' productivity. However, existing approaches in industry and academia typically employ either dynamic or static remediation methods. Dynamic remediation involves writing and running a reproducible script based on the problem description, and then locating and remediating the error based on the dynamic error message. Static remediation involves retrieving the most relevant code snippets from the code repository based on the problem description and directly remediating them. However, both approaches have their limitations, resulting in a low success rate in resolving the problem.

[0021] To solve or alleviate the above problems and / or other potential problems, embodiments of the present disclosure provide a method for repairing code. This method significantly improves the success rate of repairing defective code by organically combining static and dynamic repair methods.

[0022] The following describes the basic principles and implementations of the present disclosure with reference to the accompanying drawings. It should be understood that the exemplary embodiments provided are only intended to enable those skilled in the art to better understand and implement the embodiments of the present disclosure, and are not intended to limit the scope of the present disclosure in any way.

[0023] Figure 1 1 shows a schematic diagram of an environment 100 in which various embodiments of the present disclosure can be implemented. Figure 1 As shown, the environment 100 involves a problem description 101, a code repair system 102, a generative model 103, a code repository 104, and a target patch 105. The code repository 104 can be used to store the source code of the development project and has a version control function, allowing developers to track each code change, compare the differences between different versions, and roll back to the previous version when necessary. The code repository 104 can be deployed by the developer on a remote server such as a developer platform for other users to download, study, and review. It is understandable that in the present disclosure, the code repository 104 contains defective code and can affect the normal operation of the source code in the code repository 104.

[0024] In some embodiments, problem description 101 may be a detailed description of the defective code, published on, for example, a developer platform, after a user discovers the defective code while running the code in code repository 104. In some embodiments, problem description 101 may also include a patch created by the user to fix the defective code, or a reproduction file for reproducing the code defect.

[0025] In some embodiments, problem description 101 may be provided to code repair system 102 to generate a target patch 105 for repairing defective code. Code repair system 102 may also generate corresponding prompt words based on problem description 101 and input the prompt words into generative model 103 to obtain target patch 105. In some embodiments, code repair system 102 may be deployed on a local server or a cloud server, which is not a limitation of this disclosure.

[0026] The following references Figure 2 Further describes the process of generating target patches to fix defective code. Figure 2 1 shows a flow chart of a method for repairing code according to an embodiment of the present disclosure. In some embodiments, method 200 may be performed by, for example, Figure 1 It should be understood that the method 200 may also include additional actions not shown and / or may omit actions shown, and the scope of the present disclosure is not limited in this respect.

[0027] like Figure 2As shown, in box 210, method 200 may include: determining the defective code in the code repository based on the problem description. Since the code in the code repository 104 is usually stored in multiple different files and is difficult to find, in some embodiments, the code repair system 102 can determine the defective code in combination with the problem description 101 and / or the code knowledge graph. The code knowledge graph is the application of knowledge graph technology in the field of code understanding and analysis. It can store the code in the code repository 104 in the form of a database, and represent the entities (such as variables, functions, classes, etc.), relationships (such as call relationships, inheritance relationships, etc.) and attributes (such as types, scopes, etc.) in the code in a structured manner.

[0028] In some embodiments, code repair system 102 can also identify defective code by combining problem description 101 with code navigation tools built into the integrated development environment. For example, code repair system 102 can use a language server to search for potential defects in the code repository 104, including syntax errors, type mismatches, and undefined variables or functions. Furthermore, the language server also has functions such as definition jumps and reference lookup, which, combined with problem description 101, can efficiently identify defective code.

[0029] At block 220, method 200 may include selecting a repair method from a static repair method and a dynamic repair method to repair the defective code based on the defective code and the problem description. A static repair method refers to a repair method that directly modifies the defective code without running a problem reproduction script, while a dynamic repair method refers to a repair method that debugs the defective code by running a problem reproduction script. In some embodiments, code repair system 102 may use generative model 103 to select one of the static repair method and the dynamic repair method based on the defective code and the problem description 101.

[0030] For example, if the user uploads a problem description 101 with a patch that can directly fix the defective code, the code repair system 102 may select a static repair method to repair the defective code. For another example, if the user uploads a problem description 101 with a reproduction file that can reproduce the code defect, the code repair system 102 may select a dynamic repair method to repair the defective code.

[0031] At block 230 , method 200 may include generating candidate patches for repairing the defective code based on the selected repair method. In some embodiments, if the code repair system 102 chooses to use a static repair method to repair the defective code, the code repair system 102 may determine appropriate prompt words based on the defective code and the problem description 101 and input the prompt words into the generative model 103 to automatically generate candidate patches. To avoid the uncontrollability of the output results of the generative model 103 , in some embodiments, the code repair system 102 may first generate a plurality of preliminary candidate patches based on the generative model 103 and then determine one of the preliminary candidate patches as a candidate patch from the plurality of preliminary candidate patches, for example, by voting.

[0032] In some embodiments, if the code repair system 102 chooses to use a dynamic repair method to repair defective code, the code repair system 102 may first generate a problem reproduction file based on the problem description 101 and the defective code to reproduce the code problem described in the problem description 101. Then, the code repair system 102 may generate preliminary candidate patches based on the problem reproduction file using the generative model 103.

[0033] After obtaining the preliminary candidate patch, the code repair system 102 can test the preliminary candidate patch to determine whether it can repair the defective code. In order to keep the code warehouse 104 from being contaminated, in some embodiments, the defective code repair test can be performed in a sandbox environment. The sandbox environment is an isolated, secure computing environment for running untrusted code or applications to prevent them from causing damage to other parts of the system or network. The sandbox environment works by limiting the resources (such as file systems, networks, memory, etc.) that applications or codes can access, thereby ensuring that even if there is malicious behavior in the code, it will not have a serious impact on the entire system or network. If the preliminary candidate patch can repair the defective code, the code repair system 102 can use the preliminary candidate patch as a candidate patch. In some embodiments, if the preliminary candidate patch cannot repair the defective code, the code repair system 102 can regenerate the preliminary candidate patch until a preset threshold of the number of regenerations is reached.

[0034] At block 240 , method 200 may include determining whether the generated candidate patch is capable of repairing the defective code. Whether a candidate patch is determined from a plurality of preliminary candidate patches using a static repair method or a candidate patch obtained and tested using a dynamic repair method, it is possible that the candidate patch may not successfully repair the defective code. In some embodiments, code repair system 102 may perform a final test in a sandbox environment based on a candidate patch obtained using one of the repair methods to determine whether the candidate patch is capable of repairing the defective code.

[0035] At block 250 , method 200 may include, in response to determining that the candidate patch cannot repair the defective code, determining to use a different repair method from the static repair method and the dynamic repair method to repair the defective code. In some embodiments, code repair system 102 may further iteratively apply the static repair method and the dynamic repair method until a candidate patch that can repair the defective code is obtained as a target patch. If the number of iterations reaches a preset threshold without obtaining a target patch, code repair system 102 may select one of the candidate patches generated historically as the target patch.

[0036] The following references Figure 3 Further describe the process of fixing defective code based on the problem description. Figure 3 FIG. 3 shows a schematic diagram of the structure of a code repair system 300 according to an embodiment of the present disclosure. The code repair system 300 may be Figure 1 An exemplary implementation of the code repair system 102 is shown. Figure 3 As shown, the problem description 101 can first be provided to the search module 301 of the code repair system 300 to determine the defective code in the code repository. In the process of determining the defective code, the search module 301 can combine the language server 302 and the code knowledge graph 303 to improve the search efficiency.

[0037] In some embodiments, after the defective code is determined, the planning module 304 of the code repair system 102 may determine whether to use a static repair method or a dynamic repair method to obtain candidate patches 307 for repairing the defective code. If the planning module 304 chooses to use the static repair method, the editing module 305 of the code repair system 102 may obtain candidate patches 307-1. Based on the problem description 101 and the defective code, the editing module 305 may first obtain preliminary candidate patches 306-1, preliminary candidate patches 306-2, ..., and preliminary candidate patches 306-n (collectively referred to as preliminary candidate patches 306), and then select the one from the preliminary candidate patches 306 that is most likely to successfully repair the defective code as candidate patch 307-1.

[0038] In some embodiments, after obtaining candidate patch 307-1, evaluation module 313 of code repair system 102 may determine whether candidate patch 307-1 can successfully repair the defective code. If candidate patch 307-1 can successfully repair the defective code, it is determined as target patch 314. Otherwise, evaluation module 313 invokes reproduction module 308 of code repair system 102 to initiate a dynamic repair process and regenerate candidate patch 307.

[0039] During the dynamic repair process, the reproduction module 308 can first generate a reproduction file 309 based on the problem description 101 and the defective code to reproduce the user problem. Then, the reproduction file 309 can be provided to the programming module 310 to generate a preliminary candidate patch. The testing module 312 can receive the preliminary candidate patch and test the defect code repair. If the preliminary candidate patch can successfully repair the defective code, the code repair system 102 can directly determine it as a candidate patch 307-2 and continue to hand it over to the evaluation module 313 for further defect code repair testing. Conversely, the programming module 310 can regenerate a new preliminary candidate patch and hand it over to the testing module 312 for preliminary testing until the preset regeneration number threshold is reached. In some embodiments, the above-mentioned reproduction process and testing process can be completed in the sandbox environment 311 to avoid contaminating the code warehouse 104.

[0040] If the evaluation module 313 determines that candidate patch 307-2 can successfully repair the defective code, it will be determined as the target patch 314. Otherwise, the evaluation module 313 will call the editing module 305 of the code repair system 102 to restart the static repair process again until the number of iterations of alternating static and dynamic repair methods reaches a preset threshold. If the evaluation module 313 still does not detect a target patch that meets the requirements after reaching the preset threshold, the code repair system 102 can select one of the previously generated candidate patches as the output result.

[0041] In some embodiments, the search module 301, planning module 304, editing module 305, reproduction module 308, programming module 310, testing module 312, and evaluation module 313 can all be agents connected to the generative model 103, each with its own goals and tasks. Agents can make complex decisions and execute tasks by understanding and generating natural language, and possess a certain degree of autonomy and interaction. Based on assigned goals and tasks, they can break down large tasks into smaller, manageable sub-goals and plan future action paths.

[0042] The above reference Figures 1 to 3 Compared with existing code repair methods, the solution for repairing code defects disclosed in the present invention organically combines static repair methods and dynamic repair methods, thereby greatly improving the success rate of repairing defective code.

[0043] Figure 4 FIG. 4 shows a schematic block diagram of an apparatus 400 for repairing code according to an embodiment of the present disclosure. Figure 4As shown, the apparatus 400 includes: a defect code determining unit 410 , a repair method selecting unit 420 , a candidate patch generating unit 430 , a candidate patch determining unit 440 and a repair method switching unit 450 .

[0044] In some embodiments, the defect code determination unit 410 is configured to determine the defect code in the code bin based on the problem description; the repair method selection unit 420 is configured to select a repair method from a static repair method and a dynamic repair method to repair the defect code based on the defect code and the problem description; the candidate patch generation unit 430 is configured to generate a candidate patch for repairing the defect code based on the selected repair method; the candidate patch determination unit 440 is configured to determine whether the generated candidate patch can repair the defect code; the repair method switching unit 450 is configured to determine to use another different repair method from the static repair method and the dynamic repair method to repair the defect code in response to determining that the candidate patch cannot repair the defect code.

[0045] It should be noted that the reference Figures 1 to 3 Further actions or steps shown can be performed by Figure 4 For example, the apparatus 400 may include more modules or units to implement the actions or steps described above, or Figure 4 Some of the units or modules shown may be further configured to implement the actions or steps described above, which will not be repeated here.

[0046] Figure 5 A schematic block diagram of an example device 500 that can be used to implement an embodiment of the present disclosure is shown. As shown, the device 500 includes a computing unit 501 that can perform various appropriate actions and processes based on computer program instructions stored in a read-only memory (ROM) 502 or loaded from a storage unit 506 into a random access memory (RAM) 503. Various programs and data required for the operation of the device 500 can also be stored in the RAM 503. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0047] Various components in device 500 are connected to I / O interface 505, including: an input unit 506, such as a keyboard, mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a magnetic disk, optical disk, etc.; and a communication unit 509, such as a network card, modem, wireless communication transceiver, etc. The communication unit 509 allows device 500 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0048] The computing unit 501 can be various general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as method 200. For example, in some embodiments, method 200 can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, it can be implemented Figure 1 Code repair system 102, Figure 3 Alternatively, in other embodiments, the computing unit 501 may be configured to implement the code repair system 300 described above, or to perform one or more steps of the method 200 described above. Figure 1 Code repair system 102, Figure 3 The code repair system 300 or the execution method 200 is provided.

[0049] In some embodiments, the methods and processes described above may be implemented as a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present disclosure.

[0050] A computer-readable storage medium can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.

[0051] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.

[0052] The computer program instructions for performing the disclosed operation can be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data or source code or the object code written in any combination of one or more programming languages, wherein the programming languages ​​include object-oriented programming languages, and conventional procedural programming languages.Computer-readable program instructions can be performed completely on the user's computer, partially on the user's computer, performed as an independent software package, partly on the user's computer and partly on a remote computer, or performed completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer by any type of network-including local area network (LAN) or wide area network (WAN), or can be connected to an external computer (such as utilizing an Internet service provider to connect by the Internet). In certain embodiments, by utilizing the state information of computer-readable program instructions to carry out personalized customization electronic circuits, such as programmable logic circuits, field programmable gate arrays (FPGAs) or programmable logic arrays (PLA), this electronic circuit can perform computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0053] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine such that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0054] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0055] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and the part of the module, program segment or instruction contains one or more executable instructions for realizing the prescribed logical function. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart, can be implemented by a dedicated hardware-based system that performs the prescribed function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0056] While various embodiments of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or technical improvements to existing technologies, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for repairing code, comprising: Based on the problem description, identify the defective code in the code repository; Based on the defect code and the problem description, selecting a repair method from a static repair method and a dynamic repair method to repair the defect code; Based on the selected repair method, generating a candidate patch for repairing the defective code; Determining whether the generated candidate patch can repair the defective code; as well as In response to determining that the candidate patch cannot repair the defective code, it is determined to use another different repairing method among the static repairing method and the dynamic repairing method to repair the defective code.

2. The method of claim 1 , wherein determining defective code in a code bin comprises: Based on the problem description and the code knowledge graph, the defective code in the code warehouse is determined, wherein the code knowledge graph stores the code in the code warehouse in the form of a database.

3. The method according to claim 1 or 2, wherein determining defective code in a code bin comprises: The defective code in the code repository is determined based on the problem description and a code navigation tool built into an integrated development environment.

4. The method according to any one of claims 1 to 3, wherein selecting a repair method from a static repair method and a dynamic repair method to repair the defective code comprises: A generative model is used to select one of the static repair method and the dynamic repair method based on the defect code and the problem description, wherein the static repair method directly repairs the defect code without running a problem reproduction script, and the dynamic repair method repairs the defect code by running a problem reproduction script.

5. The method according to any one of claims 1 to 4, wherein when the selected repair method is the static repair method, generating a candidate patch for repairing the defective code comprises: Based on the defect code and the problem description, generate a plurality of preliminary candidate patches; as well as A preliminary candidate patch is determined from the plurality of preliminary candidate patches as the candidate patch.

6. The method according to any one of claims 1 to 4, wherein when the selected repair method is the dynamic repair method, generating a candidate patch for repairing the defective code comprises: Generate a problem reproduction script based on the problem description and the defect code; Generate preliminary candidate patches based on the problem reproduction script; Determining whether the generated preliminary candidate patch can repair the defective code; as well as In response to the preliminary candidate patch being able to repair the defective code, the preliminary candidate patch is determined as the candidate patch.

7. The method according to claim 6, further comprising: In response to the preliminary candidate patch being unable to repair the defective code, the preliminary candidate patch is regenerated until a preset threshold of the number of regeneration times is reached.

8. The method according to any one of claims 1 to 7, wherein determining whether the generated candidate patch is capable of repairing the defective code comprises: A generative model is used to determine whether the candidate patch can repair the defective code.

9. The method according to any one of claims 1 to 8, further comprising: By iteratively using the static repair method and the dynamic repair method, a candidate patch capable of repairing the defective code is obtained as a target patch; as well as In response to the number of iterations reaching a preset threshold, a candidate patch is selected from the generated multiple candidate patches as the target patch.

10. A system for use, comprising: a defective code determining unit, configured to determine defective codes in the code bin based on the problem description; a repair method selection unit configured to select a repair method from a static repair method and a dynamic repair method to repair the defect code based on the defect code and the problem description; a candidate patch generating unit, configured to generate a candidate patch for repairing the defective code based on the selected repair method; a candidate patch determining unit, configured to determine whether the generated candidate patch is capable of repairing the defective code; as well as The repair method switching unit is configured to, in response to determining that the candidate patch cannot repair the defective code, determine to use another different repair method from the static repair method and the dynamic repair method to repair the defective code.

11. A computing device comprising: at least one processing unit; At least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the computing device to perform the method of any one of claims 1 to 9.

12. A computer storage medium comprising machine-executable instructions which, when executed by a device, cause the device to perform the method of any one of claims 1 to 9.

13. A computer program product comprising machine-executable instructions which, when executed by a device, cause the device to perform the method according to any one of claims 1 to 9.