Method and apparatus for code repair, and device and product

By combining static and dynamic repair methods, candidate patches are automatically generated and tested, solving the problem of low success rate in code repair in existing technologies and achieving efficient code repair.

WO2026065176A1PCT designated stage Publication Date: 2026-04-02BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-09-28
Publication Date
2026-04-02

AI Technical Summary

Technical Problem

Existing automated code repair methods are usually limited to one of static or dynamic repair methods, resulting in a low success rate for code repair.

Method used

By combining static and dynamic repair methods, a generative model is used to automatically generate candidate patches, which are then tested in a sandbox environment. The most suitable repair method is iteratively selected until success is achieved.

Benefits of technology

It significantly improved the success rate and efficiency of fixing defective code, reduced the tediousness of manual fixing, and increased the productivity of the development team.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024122083_02042026_PF_FP_ABST
    Figure CN2024122083_02042026_PF_FP_ABST
Patent Text Reader

Abstract

A method and apparatus for code repair, and a computing device, a computer-readable storage medium and a computer program product. The method comprises: on the basis of an issue description, determining a defective code in a code repository; on the basis of the defective code and the issue description, selecting one of a static repair method and a dynamic repair method to repair the defective code; on the basis of the selected repair method, generating a candidate patch for repairing the defective code; 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 the other one of the static repair method and the dynamic repair method to repair the defective code.
Need to check novelty before this filing date? Find Prior Art

Description

Method, device, apparatus and product for repairing code TECHNICAL FIELD

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

[0002] Developers usually use some version control and collaboration platforms for hosting and managing software code, which usually provide components to track and manage tasks, bug reports, feature requests, etc. in a project. Users can record various issues in the process of software development and use with natural language. These tools not only help team members to describe and track issues in detail and repair the related code, but also provide a collaborative platform for developers to discuss solutions and implementation schemes.

[0003] However, when the size and complexity of the project increase, manually handling issues and repairing code can be quite cumbersome and time-consuming. In this case, it is particularly important to automate the mechanism of solving problems and repairing code, which can greatly improve the work efficiency of developers and enable them to focus on more creative and complex tasks. Therefore, developing an effective method to automatically solve problems and repair code can greatly improve the productivity of the team.

[0004] SUMMARY

[0005] Therefore, the present disclosure provides a method, device, computing apparatus, 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.

[0006] According to a first aspect of the present disclosure, a method for repairing code is provided, comprising: determining a defective code in a code repository based on an issue description; selecting one repair method from static repair methods and dynamic repair methods to repair the defective code based on the defective code and the issue 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 methods and the dynamic repair methods to repair the defective code.

[0007] According to a second aspect of the disclosure, there is provided an apparatus for fixing code, comprising: a defect code determining unit configured to determine a defect code in a code repository based on a problem description; a fix method selecting unit configured to select one fix method from a static fix method and a dynamic fix method to fix the defect code based on the defect code and the problem description; a candidate patch generating unit configured to generate a candidate patch for fixing the defect code based on the selected fix method; a candidate patch determining unit configured to determine whether the generated candidate patch can fix the defect code; and a fix method switching unit configured to determine to use a different fix method from the other one of the static fix method and the dynamic fix method to fix the defect code in response to determining that the candidate patch cannot fix the defect code.

[0008] According to a third aspect of the disclosure, there is provided 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 as described in the first aspect of the disclosure.

[0009] According to a fourth aspect of the disclosure, there is provided a non-transitory computer storage medium comprising machine executable instructions that, when executed by a device, cause the device to perform the method as described in the first aspect of the disclosure.

[0010] According to a fifth aspect of the disclosure, there is provided a computer program product comprising machine executable instructions that, when executed by a device, cause the device to perform the method as described in the first aspect of the disclosure.

[0011] It is to be understood that the Summary is not intended to identify key or essential features of embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features, details, and advantages of the disclosure will become BRIEF DESCRIPTION OF DRAWINGS

[0012] The above and other objects, features and advantages of embodiments of the disclosure will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings in which:

[0013] FIG. 1 shows a schematic diagram of an example environment in which embodiments of the disclosure can be implemented;

[0014] FIG. 2 shows a flowchart of a method of fixing code according to embodiments of the disclosure;

[0015] FIG. 3 shows a structural schematic diagram of a code repair system according to an embodiment of the present disclosure;

[0016] FIG. 4 shows a block diagram of an apparatus for repairing code according to an embodiment of the present disclosure; and

[0017] FIG. 5 shows a block diagram of an electronic device according to an embodiment of the present disclosure.

[0018] In all the drawings, the same or similar reference numerals denote the same or similar elements. DETAILED DESCRIPTION

[0019] Embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be interpreted as being limited to the embodiments set forth herein, but rather, these embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It will be understood that the drawings of the present disclosure and the embodiments are for illustrative purposes only, and are not intended to limit the scope of protection of the present disclosure.

[0020] In the description of embodiments of the present disclosure, the term "comprising" and its conjugations should be understood to encompass the meanings of "including but not limited to", i.e., "comprising but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "an embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. can refer to different or similar objects unless explicitly stated otherwise. Other explicit and implicit definitions can also be included below.

[0021] As described above, automatically solving problems in code can greatly improve the work efficiency of the development team. However, the existing industry and academia usually adopt one of the dynamic repair method or the static repair method when automatically solving problems in code. The dynamic repair method refers to a scheme of writing a reproduction script according to the information in the problem description, running the reproduction script, and positioning and repairing errors according to dynamic error information; the static repair method refers to a process of retrieving the most relevant code fragments from the code repository according to the information in the problem description, and directly repairing. However, these two methods have their own limitations, resulting in a low success rate of solving the final problem.

[0022] To solve or alleviate the above problems and / or other potential problems, embodiments of the present disclosure propose a method for repairing code. The method combines static repair methods and dynamic repair methods organically, greatly improving the success rate of repairing defective code.

[0023] The basic principles and implementations of the present disclosure are explained hereinafter with reference to the accompanying drawings. It should be understood that the exemplary embodiments are given only so that those skilled in the art can better understand and implement embodiments of the present disclosure, and do not limit the scope of the present disclosure in any way.

[0024] FIG. 1 shows a schematic diagram of an environment 100 capable of implementing embodiments of the present disclosure. As shown in FIG. 1, 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 source code of a development project and has a version control function, allowing developers to track changes to each piece of code, compare differences between different versions, and roll back to previous versions when needed. The code repository 104 can be deployed by the developer on a remote server, such as a developer platform, for other users to download, learn, and review. It can be understood 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.

[0025] In some embodiments, the problem description 101 can be a detailed description of the defective code published by the user on the developer platform after running the code in the code repository 104 and discovering the defective code. In some embodiments, the problem description 101 can also include a patch created by the user to fix the defective code, or a reproduction file to reproduce the code defect.

[0026] In some embodiments, the problem description 101 can be provided to the code repair system 102 to generate the target patch 105 for repairing the defective code. The code repair system 102 can also generate a corresponding prompt word based on the problem description 101, and input the prompt word into the generative model 103 to obtain the target patch 105. In some embodiments, the code repair system 102 can be deployed in a local server or a cloud server, which is not limited by the present disclosure.

[0027] The process of generating a target patch to repair defective code is further described below with reference to FIG. 2. FIG. 2 shows a flowchart of a method of repairing code according to embodiments of the present disclosure. In some embodiments, the method 200 can be implemented by, for example, the code repair system 102 shown in FIG. 1. It should be understood that the method 200 can also include additional actions not shown and / or can omit the actions shown, and the scope of the present disclosure is not limited in this regard.

[0028] As shown in FIG. 2, at block 210, the method 200 can 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 an application of the knowledge graph technology in the field of code understanding and analysis, which 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.

[0029] In some embodiments, the code repair system 102 can also determine the defective code in combination with the problem description 101 and the code navigation tool built in the integrated development environment. For example, the code repair system 102 can find the potential defects of the code in the code repository 104 through the language server, including syntax errors, type mismatches, undefined variables or functions, etc. In addition, the language server also has the functions of definition jump, reference lookup, etc., which can be combined with the problem description 101 to efficiently determine the defective code.

[0030] At block 220, the method 200 can include selecting one of a static repair method and a dynamic repair method to repair the defective code based on the defective code and the problem description. The static repair method refers to a repair method that directly modifies the defective code without running the problem reproduction script, while the dynamic repair method refers to a repair method that debugs the defective code by running the problem reproduction script. In some embodiments, the code repair system 102 can use the 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.

[0031] For example, if the user attaches a patch that can directly repair the defective code in the uploaded problem description 101, the code repair system 102 can select the static repair method to repair the defective code. For another example, if the user attaches a reproduction file that can reproduce the code defect in the uploaded problem description 101, the code repair system 102 can select the dynamic repair method to repair the defective code.

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

[0033] In some embodiments, if the code repair system 102 selects to use the dynamic repair method to repair the defective code, the code repair system 102 can 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 can generate a preliminary candidate patch through the generative model 103 based on the problem reproduction file.

[0034] 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 repository 104 from being contaminated, in some embodiments, the test of the defective code repair can be performed in a sandbox environment. A sandbox environment is an isolated, secure computing environment used to run 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 an application or code 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 take the preliminary candidate patch as the 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.

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

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

[0037] The process of repairing the defective code based on the problem description is further described below with reference to FIG. 3. FIG. 3 shows a structural schematic diagram of a code repair system 300 according to an embodiment of the present disclosure. The code repair system 300 can be an exemplary implementation of the code repair system 102 shown in FIG. 1. As shown in FIG. 3, the problem description 101 can be first provided to a 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 a language server 302 and a code knowledge graph 303 to improve the search efficiency.

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

[0039] In some embodiments, after the candidate patch 307-1 is obtained, a judgment module 313 of the code repair system 102 can determine whether the candidate patch 307-1 is able to successfully repair the defective code. If the candidate patch 307-1 is able to successfully repair the defective code, it is determined as a target patch 314. Otherwise, the judgment module 313 will invoke a reproduction module 308 of the code repair system 102 to start a dynamic repair process to regenerate the candidate patch 307.

[0040] During the dynamic repair process, the reproduction module 308 can first generate a reproduction file 309 based on the problem description 101 and the defect 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 test module 312 can receive the preliminary candidate patch and perform a test of the defect code repair. If the preliminary candidate patch can successfully repair the defect code, the code repair system 102 can directly determine it as the candidate patch 307-2 and continue to be handed over to the evaluation module 313 for further defect code repair test. Otherwise, the programming module 310 can regenerate a new preliminary candidate patch and hand it over to the test module 312 for preliminary test until a preset threshold of the number of regenerations is reached. In some embodiments, the above reproduction process and test process can be completed in the sandbox environment 311 to avoid polluting the code repository 104.

[0041] If the evaluation module 313 judges that the candidate patch 307-2 can successfully repair the defect code, it is determined as the target patch 314. Otherwise, the evaluation module 313 will call the editing module 305 of the code repair system 102 to start a new round of static repair process, until the iteration number of alternating use of the static repair method and the dynamic repair method reaches a preset threshold. If the evaluation module 313 still does not detect a target patch meeting the requirements after reaching the preset threshold, the code repair system 102 can select one of the historically generated candidate patches as the output result.

[0042] In some embodiments, the above search module 301, planning module 304, editing module 305, reproduction module 308, programming module 310, test module 312, and evaluation module 313 can be agents connected to the generative model 103 and have their respective goals and tasks. The agent can make complex decisions and perform tasks by understanding and generating natural language, and has a certain autonomy and interaction ability. It can decompose large tasks into smaller, manageable sub-goals according to the assigned goals and tasks, and plan future action paths.

[0043] The above describes exemplary embodiments of the present disclosure with reference to FIGS. 1-3. Compared with existing code repair methods, the code defect repair scheme of the present disclosure combines static repair methods and dynamic repair methods organically, thereby greatly improving the success rate of repairing defect codes.

[0044] FIG. 4 shows a schematic block diagram of an apparatus 400 for repairing code according to an embodiment of the present disclosure. As shown in FIG. 4, the apparatus 400 includes a defect code determination unit 410, a repair method selection unit 420, a candidate patch generation unit 430, a candidate patch determination unit 440, and a repair method switching unit 450.

[0045] In some embodiments, the defect code determining unit 410 is configured to determine a defect code in the code repository based on the problem description; the repair method selecting unit 420 is configured to select one repair method from the static repair method and the dynamic repair method to repair the defect code based on the defect code and the problem description; the candidate patch generating unit 430 is configured to generate a candidate patch for repairing the defect code based on the selected repair method; the candidate patch determining unit 440 is configured to determine whether the generated candidate patch can repair the defect code; and 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.

[0046] It should be noted that more actions or steps shown in FIGS. 1-3 can be implemented by the apparatus 400 shown in FIG. 4. For example, the apparatus 400 can include more modules or units to implement the actions or steps described above, or some units or modules shown in FIG. 4 can be further configured to implement the actions or steps described above. Here, no further elaboration is repeated.

[0047] FIG. 5 shows a schematic block diagram of an example device 500 that can be used to implement embodiments of the present disclosure. As shown, the device 500 includes a computing unit 501 that can perform various appropriate actions and processes according to 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 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 through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

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

[0049] The computing unit 501 can be various general and / or special purpose 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 specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs various methods and processes described above, such as the method 200. For example, in some embodiments, the method 200 can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded onto the RAM 503 and executed by the computing unit 501, the code repair system 102 of FIG. 1, the code repair system 300 of FIG. 3, or one or more steps of performing the method 200 described above can be implemented. Alternatively, in other embodiments, the computing unit 501 can be configured to implement the code repair system 102 of FIG. 1, the code repair system 300 of FIG. 3, or perform the method 200 by any other suitable means, such as by means of firmware.

[0050] In some embodiments, the methods and processes described above can be implemented as computer program products. Computer program products can include computer readable storage media having computer readable program instructions thereon for performing various aspects of the present disclosure.

[0051] Computer readable storage media can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, semiconductor, or any other suitable combination of

[0052] Computer readable program instructions described herein can be downloaded to respective computing / processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and / or a wireless network. The network can comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. A network adapter card or network interface in each computing / processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing / processing device.

[0053] Computer readable program instructions for carrying out operations of the present disclosure can be assembly-level instructions, instructions set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including object oriented programming languages and conventional procedural programming languages. The computer readable program instructions can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate array (FPGA), or programmable logic array (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.

[0054] These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer readable program instructions can also be stored in a computer readable storage medium that can include a non-transitory computer readable storage medium that can direct a computer, a programmable data processing apparatus, and / or other devices to function in a particular manner, such that the computer readable storage medium having instructions for causing an apparatus to implement one or more functions / acts specified in the flowchart and / or block diagram block or blocks is provided.

[0055] The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus or other device to produce a computer implemented process such that the instructions which execute on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0056] The flow diagrams and the block diagrams in the drawings are presented to illustrate the architecture, functionality, and operation of possible implementations of devices, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams and the block diagrams can represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logic functions. In some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flow diagrams, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and

[0057] Embodiments of the present disclosure have been described above, and the description is intended to be illustrative of the embodiments and not restrictive. Many modifications and variations of the described embodiments are possible and are within the scope of the disclosure. The selection of terms is intended to best describe the principles of the embodiments, practical application, or technical improvements over the technology found in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for repairing code, comprising: determining a defective code in a code repository based on a problem description; selecting one 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 a different repair method from the other one of the static repair method and the dynamic repair method to repair the defective code.

2. The method of claim 1, wherein determining a defective code in a code repository comprises: determining the defective code in the code repository based on the problem description and a code knowledge graph, wherein the code knowledge graph stores codes in the code repository in a form of a database.

3. The method of claim 1 or 2, wherein determining a defective code in a code repository comprises: determining the defective code in the code repository based on the problem description and a code navigation tool built-in in an integrated development environment.

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

5. The method of 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: generating a plurality of preliminary candidate patches based on the defective code and the problem description; and determining one preliminary candidate patch from the plurality of preliminary candidate patches as the candidate patch.

6. The method of 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: generating a problem reproduction script based on the problem description and the defective code; generating a preliminary candidate patch based on the problem reproduction script; determining whether the generated preliminary candidate patch can repair the defective code; and in response to the preliminary candidate patch being able to repair the defective code, determining the preliminary candidate patch as the candidate patch.

7. The method of claim 6, further comprising: in response to the preliminary candidate patch being unable to repair the defective code, regenerating the preliminary candidate patch until reaching a preset threshold of a number of regeneration times.

8. The method of any one of claims 1 to 7, wherein determining whether the generated candidate patch can repair the defective code comprises: determining whether the candidate patch can repair the defective code using a generative model. ​ ​ ​ 9. The method of any one of claims 1 to 8, further comprising: iteratively using the static repair method and the dynamic repair method to obtain a candidate patch that is able to repair the defective code as a target patch; and selecting one candidate patch from the generated multiple candidate patches as the target patch in response to a number of iterations reaching a preset threshold.

10. A system for, comprising: a defective code determining unit configured to determine a defective code in a code repository based on a problem description; a repair method selecting unit configured to select one 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 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 able to repair the defective 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 defective code in response to determining that the candidate patch is not able 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, cause the computing device to perform the method of any one of claims 1 to 9.

12. A computer storage medium comprising machine executable instructions that, 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 that, when executed by a device, cause the device to perform the method of any one of claims 1 to 9. ​