Code automatic repair method, system and equipment and storage medium

Through the collaborative work of the browser and the AI ​​large model, code anomalies can be automatically integrated and repaired, solving the time-consuming problem of traditional code repair and improving repair efficiency and system development efficiency.

CN120670016APending Publication Date: 2025-09-19HUNAN YUJIA COSMETICS MFG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510749384.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Traditional code repair methods are time-consuming and affect the stable operation of software systems.

Method used

Obtain code exception information through the browser's exception monitoring tool, integrate it into exception questions and send them to the preset AI model to obtain exception repair strategies, and use the exception repair tool to automatically repair the code.

Benefits of technology

Automatic code repair is achieved, which saves repair costs and improves system development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120670016A_ABST
    Figure CN120670016A_ABST
Patent Text Reader

Abstract

The invention relates to a computer software and artificial intelligence technology, and discloses an automatic code repairing method, system and device and a storage medium. The method is applied to an automatic code repairing system, the automatic code repairing system comprises a browser and a preset AI large model, and the method comprises the steps that an initial code is operated through the browser, and abnormal information of the initial code is obtained through an abnormal monitoring tool of the browser; integrating the abnormal information to generate an abnormal question, and sending the abnormal question to a preset AI large model; and obtaining an exception repair strategy generated by the AI large model according to the exception question, and repairing the initial code through an exception repair tool according to the exception repair strategy to obtain a target code. According to the method and the device, the abnormal codes can be automatically repaired, the code repairing cost is saved, and the system development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer software and artificial intelligence technology, and in particular to a code automatic repair method, system, device and storage medium. Background Art

[0002] During software system development, anomalies can occur that impact the system's normal operation, requiring timely repairs to ensure proper functioning. Traditional methods require developers to identify and repair anomalies before re-running the system. This process is time-consuming and detrimental to the stable operation of the software system. Summary of the Invention

[0003] In order to solve the problem that existing code repair methods are time-consuming, the present invention provides a code automatic repair method, system, device and storage medium.

[0004] In a first aspect, the present invention provides a method for automatically repairing code, which is applied to an automatic code repair system. The automatic code repair system includes a browser and a preset AI large model. The method includes:

[0005] Running the initial code through the browser, and obtaining abnormal information of the initial code through an abnormality monitoring tool of the browser;

[0006] Integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model;

[0007] Obtain an exception repair strategy generated by the preset AI large model according to the exception question, and use an exception repair tool to repair the initial code according to the exception repair strategy to obtain a target code.

[0008] In an optional embodiment, obtaining the abnormality information of the initial code through the abnormality monitoring tool of the browser includes:

[0009] Obtaining an abnormal code in the initial code by the abnormality monitoring tool;

[0010] An exception type, context information, and environmental information of the exception code are determined, and the exception information is generated according to the exception type, the context information, and the environmental information.

[0011] In an optional implementation, determining the exception type of the exception code includes:

[0012] Capturing the error message corresponding to the abnormal code by the abnormal monitoring tool;

[0013] Comparing the error prompt information with the preset prompt information to determine whether the preset prompt information contains the target prompt information corresponding to the error prompt information;

[0014] If so, the exception type corresponding to the error prompt information is determined according to the target prompt information.

[0015] In an optional embodiment, the method further comprises:

[0016] Testing the target code using a black box testing tool to obtain a test result, and determining whether the test result meets a preset condition;

[0017] If the test result does not meet the preset condition, a repair request is initiated to the preset AI large model according to the test result;

[0018] Obtaining a repair strategy generated by the preset AI large model according to the repair request, and performing multiple repairs on the target code based on the repair strategy;

[0019] If multiple repairs do not meet the preset conditions, an alarm will be issued.

[0020] In an optional embodiment, the method further comprises:

[0021] If the multiple repairs do not meet the preset conditions, the initial code is rolled back to a stable version, and the repair strategy is synchronously pushed to the corresponding communication device of the operation and maintenance personnel.

[0022] In an optional embodiment, the black box testing tool is constructed in the following manner:

[0023] Obtain device information, including browser version and resolution;

[0024] A headless browser sandbox is selected, and the headless browser sandbox is configured according to the browser version and the resolution to obtain the black box testing tool.

[0025] In an optional embodiment, determining whether the test result meets a preset condition includes:

[0026] If the test result meets the preset condition, the initial code is updated using the target code, and a corresponding update notification is generated and sent to the browser.

[0027] In a second aspect, the present invention provides a code automatic repair system, comprising: a browser and a preset AI large model;

[0028] The browser is used to run the initial code and obtain abnormal information of the initial code through the abnormality monitoring tool of the browser;

[0029] The browser is further configured to integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model;

[0030] The preset AI large model is used to generate an exception repair strategy based on the exception question, and to repair the initial code according to the exception repair strategy through an exception repair tool to obtain a target code.

[0031] In a third aspect, the present invention provides a computer device, comprising a processor and a memory, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the automatic code repair method described in any one of the aforementioned embodiments.

[0032] In a fourth aspect, the present invention provides a computer storage medium storing a computer program, which, when executed on a processor, implements the automatic code repair method according to any one of the aforementioned embodiments.

[0033] The embodiments of the present invention have the following beneficial effects:

[0034] The automatic code repair method provided by the present invention integrates code exception information into the form of exception questions, and sends the exception questions to the AI ​​model to obtain an exception repair strategy. The AI ​​model then calls the exception repair tool to repair the abnormal code, thereby realizing automatic repair of the abnormal code, saving the cost of code repair, and improving the efficiency of system development. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] To more clearly illustrate the technical solutions of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be construed as limiting the scope of protection of the present invention. It is possible for a person skilled in the art to derive other relevant drawings based on these drawings without inventive effort.

[0036] Figure 1 A schematic diagram of a process flow of a code automatic repair method provided by an embodiment of the present application is shown;

[0037] Figure 2 A schematic diagram of a process for generating abnormal information provided by an embodiment of the present application is shown;

[0038] Figure 3 A schematic diagram of the framework structure of a code automatic repair system provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0039] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.

[0040] The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the figures is not intended to limit the scope of the claimed invention, but rather merely represents selected embodiments of the present invention. All other embodiments derived by those skilled in the art based on the embodiments of the present invention without inventive effort are intended to be within the scope of protection of the present invention.

[0041] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or the possibility of adding one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.

[0042] Furthermore, the terms “first,” “second,” “third,” etc., are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.

[0043] Unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by those skilled in the art to which the various embodiments of the present invention pertain. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meaning as in the context of the relevant technical field and will not be interpreted as having an idealized meaning or an overly formal meaning unless clearly defined in the various embodiments of the present invention.

[0044] The following describes some embodiments of the present invention in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments may be combined with each other.

[0045] Reference Figure 1 , Figure 1 This is a flow chart of a method for automatic code repair provided in this embodiment. The method is applied to an automatic code repair system. The automatic code repair system includes a browser and a preset AI large model. The method includes:

[0046] S101: Run the initial code through the browser, and obtain abnormal information of the initial code through the abnormality monitoring tool of the browser.

[0047] Anomaly detection tools can include Sentry, an open-source error tracking and real-time monitoring tool that helps developers monitor and fix crashes. It supports multiple programming languages ​​and platforms, including Python, JavaScript, Java, and Ruby. Sentry provides a comprehensive error tracking solution that quickly identifies and fixes issues, improving software stability and user experience.

[0048] S102: Integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model.

[0049] Traditional exception information processing requires developers to find the location of the exception code and manually repair it. After the modification, testers are required to conduct a series of tests to ensure stability before the development system can be put back online.

[0050] To improve the efficiency of code repair, this embodiment integrates exception information into exception questions, and then asks them to the AI ​​big model to obtain the corresponding solution for the exception information. The AI ​​big model can be a commonly used big model or a big model specially trained according to system development.

[0051] S103: Obtain an exception repair strategy generated by the preset AI large model according to the exception question, and use an exception repair tool to repair the initial code according to the exception repair strategy to obtain a target code.

[0052] The anomaly repair tool can be a built-in tool within the AI ​​model. That is, after an anomaly question is input into the AI ​​model, the AI ​​model automatically generates a corresponding anomaly repair strategy and then calls its built-in anomaly repair tool to repair the initial code, thereby automatically locating and repairing the code. Alternatively, the anomaly repair strategy generated by the AI ​​model can be sent to the anomaly repair tool through the corresponding interface.

[0053] This embodiment integrates code exception information into the form of exception questions and sends the exception questions to the AI ​​model to obtain an exception repair strategy. The AI ​​model then calls the exception repair tool to repair the abnormal code, thereby realizing automatic repair of the abnormal code, saving the cost of code repair, and improving the efficiency of system development.

[0054] Reference Figure 2 In one embodiment, step S101 further includes: steps S1011-S1012.

[0055] S1011. Obtain an abnormal code in the initial code through the abnormality monitoring tool.

[0056] S1012: Determine the exception type, context information, and environmental information of the exception code, and generate the exception information according to the exception type, the context information, and the environmental information.

[0057] In addition to capturing and analyzing errors and exceptions in software systems, the exception monitoring tool Sentry can also monitor program performance indicators such as response time, database query speed, etc., and generate alerts based on specific time. Therefore, in addition to using Sentry to monitor some common exceptions, developers can set other exception types according to their needs. When Sentry detects the corresponding exception type of code, it generates exception information.

[0058] When repairing abnormal code, it is also necessary to determine the specific location of the abnormal code, the code's operating environment and other factors. Therefore, it is also necessary to combine various factors such as the abnormal type, context information and environmental information of the abnormal code to generate corresponding abnormal information so that the repaired code can run normally and avoid incompatibility or mismatch problems in the repaired code due to unclear parameters such as version and operating environment.

[0059] This embodiment uses an exception monitoring tool to monitor the abnormal code in the application program, and then generates exception information based on the abnormal code and various environmental factors corresponding to the code, so that the abnormal code can be directly repaired according to the abnormal information, thereby improving the efficiency of abnormal code repair.

[0060] In one embodiment, determining the exception type of the exception code includes:

[0061] Capturing the error message corresponding to the abnormal code by the abnormal monitoring tool;

[0062] Comparing the error prompt information with the preset prompt information to determine whether the preset prompt information contains the target prompt information corresponding to the error prompt information;

[0063] If so, the exception type corresponding to the error prompt information is determined according to the target prompt information.

[0064] When a fault occurs during code execution, a corresponding exception prompt will be generated. Different faults usually correspond to different exception prompts. Common exceptions include: JavaScript runtime errors, network request errors, asynchronous errors, and Vue errors, etc. These exceptions usually generate corresponding prompt information when they occur, and the Sentry tool can determine the type of exception based on this information.

[0065] For example, for JavaScript runtime errors, such as syntax errors (SyntaxError, usually caused by code writing that does not comply with JavaScript syntax rules, such as mismatched brackets, missing semicolons, etc.), reference errors (ReferenceError, this error is thrown when referencing an undefined variable), type errors (TypeError, such as calling a function on a non-function type value), etc., the Sentry tool can accurately identify these different types of JavaScript runtime errors and clearly mark the error type in the error report.

[0066] Network request errors typically occur in front-end applications. Various errors may occur during network requests, such as errors corresponding to HTTP status codes like 404 (the requested resource does not exist) and 500 (internal server error). Sentry can capture these network request errors and determine the error type based on information such as the status code, making it easier for developers to identify whether the issue is with the client request or the server processing.

[0067] Asynchronous errors include Promise rejections that are not handled, as well as errors thrown by async / await syntax. Sentry tracks and categorizes errors generated by asynchronous operations, helping developers handle errors in complex asynchronous code logic.

[0068] Vue errors are generally errors in Vue projects. For Vue projects, Sentry can identify component rendering errors, directive errors, etc. For example, when an expression calculation error occurs in a component template, or a custom directive throws an error in a hook function such as binding or updating, Sentry can report it as a specific type of Vue error.

[0069] This embodiment captures the error prompt information corresponding to the exception code through the exception monitoring tool, and determines the type of the exception code according to the error prompt information, thereby providing support for the subsequent generation of exception questions and improving the efficiency of repairing the exception code.

[0070] In one embodiment, the method further comprises:

[0071] Testing the target code using a black box testing tool to obtain a test result, and determining whether the test result meets a preset condition;

[0072] If the test result does not meet the preset condition, a repair request is initiated to the preset AI large model according to the test result;

[0073] Obtaining a repair strategy generated by the preset AI large model according to the repair request, and performing multiple repairs on the target code based on the repair strategy;

[0074] If multiple repairs do not meet the preset conditions, an alarm will be issued.

[0075] After repairing the initial code to obtain the target code, the target code needs to be tested to determine whether it can run normally. There are many methods and tools for code testing. This embodiment uses a black box testing tool to test the target code.

[0076] Black-box testing tools are characterized by strong independence, high implementation efficiency, and wide coverage. They do not require understanding the internal structure or implementation details of the code. They can perform testing only through input and output verification functions, completely decoupling testing from development and making them better suited for scenarios involving automatic code repair.

[0077] If the multiple repairs do not meet the preset conditions, the initial code is rolled back to a stable version, and the repair strategy is synchronously pushed to the corresponding communication device of the operation and maintenance personnel.

[0078] If the test result meets the preset condition, the initial code is updated using the target code, and a corresponding update notification is generated and sent to the browser.

[0079] In order to avoid the problem that a single repair may result in incomplete repair, when a repair does not meet the preset conditions, the target code can be repaired multiple times according to the repair strategy. If the exception is still not resolved after multiple repairs, an alarm message can be issued to notify the corresponding developer to check.

[0080] This embodiment tests the repaired target code through a black box testing tool, thereby improving testing efficiency. Moreover, when the target code fails the test, the target code is repaired multiple times through the AI ​​large model, avoiding the problem that a single repair may result in an incomplete repair, thereby improving the accuracy and completeness of the code repair.

[0081] In one embodiment, the black box testing tool is constructed by:

[0082] Obtain device information, including browser version and resolution;

[0083] A headless browser sandbox is selected, and the headless browser sandbox is configured according to the browser version and the resolution to obtain the black box testing tool.

[0084] Black-box testing tools can be built using a headless browser sandbox. First, you can obtain various configuration information, such as the hardware, software, network, browser version, and resolution, that the code will run on to ensure the test environment simulates real-world usage scenarios. Then, you configure the headless browser sandbox accordingly to obtain the black-box testing tool, which you can then use to test the repaired target code. Common headless browser sandboxes include Puppeteer, Selenium, and Cypress.

[0085] This embodiment constructs a corresponding black box testing tool based on information such as the code running environment, so that the tested code can be fully compatible with the running environment, thereby improving the code testing efficiency.

[0086] Reference Figure 3 , Figure 3 A schematic diagram of the framework structure of a code automatic repair system 300 provided in this embodiment includes: a browser 301 and a preset AI large model 302;

[0087] The browser 301 is used to run the initial code and obtain abnormal information of the initial code through the abnormality monitoring tool of the browser.

[0088] The browser 301 is further configured to integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model.

[0089] The preset AI big model 302 is used to generate an exception repair strategy based on the exception question, and repair the initial code according to the exception repair strategy through an exception repair tool to obtain a target code.

[0090] It can be understood that the automatic code repair system of this embodiment corresponds to the automatic code repair method of the above embodiment, and the optional items in the above embodiment are also applicable to this embodiment, so they will not be described again here.

[0091] The present invention also provides a computer device. Exemplarily, the computer device includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the computer device to execute the functions of the various modules in the above-mentioned code automatic repair method or the above-mentioned code automatic repair system.

[0092] The processor may be an integrated circuit chip with signal processing capabilities. The processor may be a general-purpose processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor may be a microprocessor or any conventional processor, etc., and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention.

[0093] The memory may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.

[0094] The present invention also provides a computer storage medium for storing the computer program used in the above-mentioned computer device. The computer storage medium may be a readable storage medium, a non-volatile storage medium, or a volatile storage medium. For example, the computer storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0095] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in alternative implementations, the functions marked in the boxes can also occur in an order 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 structure diagram and / or flowchart, as well as the combination of boxes in the structure diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.

[0096] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0097] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention.

[0098] The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed by the present invention, which should be covered by the scope of protection of the present invention.

Claims

1. A code automatic repair method, characterized in that: Applied to a code automatic repair system, the code automatic repair system includes a browser and a preset AI large model, and the method includes: Running the initial code through the browser, and obtaining abnormal information of the initial code through an abnormality monitoring tool of the browser; Integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model; Obtain an exception repair strategy generated by the preset AI large model according to the exception question, and use an exception repair tool to repair the initial code according to the exception repair strategy to obtain a target code.

2. The automatic code repair method according to claim 1, characterized in that: The obtaining of abnormal information of the initial code through the abnormality monitoring tool of the browser includes: Obtaining an abnormal code in the initial code by the abnormality monitoring tool; An exception type, context information, and environmental information of the exception code are determined, and the exception information is generated according to the exception type, the context information, and the environmental information.

3. The automatic code repair method according to claim 2, characterized in that: Determining the exception type of the exception code includes: Capturing the error message corresponding to the abnormal code by the abnormal monitoring tool; Comparing the error prompt information with the preset prompt information to determine whether the preset prompt information contains the target prompt information corresponding to the error prompt information; If so, the exception type corresponding to the error prompt information is determined according to the target prompt information.

4. The automatic code repair method according to claim 1, characterized in that: The method further comprises: Testing the target code using a black box testing tool to obtain a test result, and determining whether the test result meets a preset condition; If the test result does not meet the preset condition, a repair request is initiated to the preset AI large model according to the test result; Obtaining a repair strategy generated by the preset AI large model according to the repair request, and performing multiple repairs on the target code based on the repair strategy; If multiple repairs do not meet the preset conditions, an alarm will be issued.

5. The automatic code repair method according to claim 4, characterized in that: The method further comprises: If the multiple repairs do not meet the preset conditions, the initial code is rolled back to a stable version, and the repair strategy is synchronously pushed to the corresponding communication device of the operation and maintenance personnel.

6. The automatic code repair method according to claim 4, characterized in that: The black box testing tool is constructed in the following ways: Obtain device information, including browser version and resolution; A headless browser sandbox is selected, and the headless browser sandbox is configured according to the browser version and the resolution to obtain the black box testing tool.

7. The automatic code repair method according to claim 4, characterized in that: Determining whether the test result meets a preset condition includes: If the test result meets the preset condition, the initial code is updated using the target code, and a corresponding update notification is generated and sent to the browser.

8. A code automatic repair system, characterized in that: include: Browser and preset AI large models; The browser is used to run the initial code and obtain abnormal information of the initial code through the abnormality monitoring tool of the browser; The browser is further configured to integrate the abnormal information to generate abnormal questions, and send the abnormal questions to the preset AI model; The preset AI large model is used to generate an exception repair strategy based on the exception question, and to repair the initial code according to the exception repair strategy through an exception repair tool to obtain a target code.

9. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the automatic code repair method according to any one of claims 1 to 7.

10. A computer storage medium, characterized in that The device stores a computer program, which, when executed on a processor, implements the automatic code repair method according to any one of claims 1 to 7.