Selective validation of a portion of a server response to a client request

A portion of a server response to a client request can be selectively validated according to some examples described herein. In one example, a system can receive a response from a server to an application programming interface (API) request transmitted by a client application. The response can include target data and other data. The system can determine that the target data is to be validated. In response to determining that the target data is to be validated, the system allow a validation process to be performed on the target data and prevent the validation process from being performed on the other data.

TECHNICAL FIELD

The present disclosure relates generally to server responses to client requests in a client-server computer architecture. More specifically, but not by way of limitation, this disclosure relates to validating a selected portion of a dataset provided by a server as a response to an application programming interface (API) request from a client application.

BACKGROUND

A client-server architecture can include a client side with a client device and a server side with a server. The client device may execute a client application to perform some functionality. The client application may interact with the server, which can perform backend operations that support the client application. Examples of the backend operations can include storing, retrieving, and organizing data.

The interactions between the client application and the server can be facilitated using an application programming interface (API). An API can include a defined set of rules that dictate how computers or applications can communicate with one another. Generally, the client application can transmit requests to an API hosted by the server. These requests can be referred to as API requests. The server can receive the API requests and transmit appropriate responses to the client application. For example, the client application can transmit a request for a dataset to the API of the server. In response to receiving the request, the server can obtain the dataset from a database (e.g., on the server side) and transmit the dataset back to the client application.

DETAILED DESCRIPTION

In a typical client-server architecture, a client application executing on a client device may need a dataset to perform a particular computing operation. To obtain the dataset, the client device can transmit a request for the dataset to an application programming interface (API) of a server. The server can receive the request and transmit a response that includes the dataset back to the client application. Before the client application uses the received dataset to perform the computing operation, the client application may validate the entire dataset to ensure that it is compatible with the client application. Validating the dataset may involve ensuring that the dataset is properly formatted (e.g., has an appropriate syntax or structure), includes a certain set of parameters, and satisfies other criteria. If the client application determines that any portion of the dataset is invalid, the client application may return an error value. This can negatively impact the functionality of the client application, for example, by preventing the client application from performing the particular computing operation. If the client application determines that the entire dataset is valid, the client application is then allowed to use the dataset in performing the particular computing operation.

While the above validation process can help ensure that a returned dataset is compatible with the client application before the client application attempts to use the dataset, it can also raise problems in certain scenarios. For example, APIs can undergo revision over time. An older version of an API may be programmed to return a first set of parameters in response to a particular API request, while a newer version of the API may be programmed to return a second set of parameters in response to the same API request. If the second set of parameters includes more, fewer, or different parameters than is expected by the client application, the validation process may fail. The main approach currently used to fix this problem involves a developer creating a software update that accounts for these API changes and then providing the software update to any number of client devices running the client application. This can be a time consuming, repetitive, and tedious manual process that may be error prone. And each time a new software update is released, the client devices may need to download the software update from a host server and install the software update, which can consume the network bandwidth, processing power, storage, and memory of both the host server and the client devices.

Some examples of the present disclosure can overcome one or more of the abovementioned problems by allowing for a validation process to be executed on a selected subpart of a dataset (e.g., rather than the entire dataset) returned from a server in response to an API request by a client application. The particular subpart of the dataset to be validated can be selected and dynamically updated by modifying one or more settings, which may be located in a configuration file or elsewhere. A remainder of the dataset can be ignored and thus may not undergo the validation process. With this approach, the validation process can be customized in a way that is easier and faster as compared to using software updates. This approach can also mitigate the negative impacts of API revisions on client-application functionality, without requiring the time and effort to create a full software update and without requiring the consumption of computing resources associated with hosting, downloading, and installing such updates.

As one particular example, a client device can include a client application. The client application can include a validation engine for executing a validation process on a dataset returned from a server in response to an API request. The validation engine may be built into the client application, for example embedded in the source code of the client application. The client device can also include a selection engine that can control which part or parts of the dataset returned from the server are to be input to the validation engine. The selection engine may or may not be part of the client application. In some examples, the client application can transmit a request for a target dataset to an API associated with a server. The server can receive the request and provide a response that includes the target dataset to the client device. The selection engine can intercept the response, extract a selected portion of the target dataset, and provide the selected portion of the target dataset to the validation engine to undergo the validation process. The particular portion of the target dataset that is selected can be dictated by settings in a configuration file or elsewhere. The selection engine can ignore a remainder of the target dataset, thereby blocking the remainder of the target dataset from undergoing the validation process. Blocking the remainder of the target dataset from undergoing the validation process can prevent the client application from breaking, for example if the target dataset includes more parameters than is expected by the validation engine.

FIG.1is a block diagram of an example of a system100for selective validation of a portion of a server response in accordance with some aspects of the present disclosure. The system100includes a client device102, such as a laptop computer, desktop computer, tablet, e-reader, mobile phone, or wearable device. The client device102can execute a client application114. Examples of the client application114can include a game such as a mobile game; a utility application such as a word processor, a website browser, or an e-mail client; or a communication application such as a text chat application or a video conferencing application.

During operation, the client application114can interact with a server104via one or more networks106, such as a local area network or the Internet. The client application114can interact with the server104using a request-response model facilitated by an API108. The API108may be hosted by the server104or may otherwise be associated with the server104. In particular, the client application114can transmit a request110for a dataset124to the API108associated with the server104. The server104can receive the request110via the API108, obtain the requested dataset124, and transmit a response112back to the client device102that includes the requested dataset124. The server104may obtain the requested dataset124from any suitable source, for example from a database or from another server.

The dataset124can include target data120for use by the client application114in performing a particular computing operation132, as well as other data122that is extraneous to performing the particular computing operation132. This may occur because an older version of the API108may have only returned the target data120, but over time, the API108may have been updated to also incorporate the other data122into the response112for various reasons. The inclusion of the other data122may cause problems during a validation process, since the other data122may not be an expected part of the response112. For example, the client application114may have been programmed to work with the older version of the API108rather than the newer version of the API108, and therefore the client application114may not expect the other data122in the response112.

To mitigate the abovementioned problems, the client device102may also include a selection engine118. The selection engine118is software that can intercept the response112prior to the response112reaching a validation engine116configured to implement the validation process. After intercepting the response112, the selection engine118can analyze the dataset124to identify which portions should be forwarded to the validation engine116and which portions should be ignored. For example, the selection engine118can access a configuration file126that includes settings128specifying which portion(s) of the dataset124correspond to target data120that is to be forwarded to the validation engine116. The settings128may additionally or alternatively specify which portion(s) of the dataset124correspond to other data122that is to be ignored. Based on the settings128, the selection engine118can parse the dataset124into the target data120and the other data122. The selection engine118can then forward the target data120to the validation engine116and prevent transmission of the other data122to the validation engine116.

The validation engine116is software that can perform the validation process on the target data120received from the selection engine118. The validation process can involve determining whether the target data120satisfies one or more predefined criteria. One example of the predefined criteria can include a formatting criteria. The target data120can be deemed to satisfy the formatting criteria if the target data120conforms to a predesignated format, such as a JavaScript Object Notation (JSON) or eXtensible Markup Language (XML) format. The target data120can be deemed not to satisfy the formatting criteria if the target data120does not conform to the predesignated format. The validation engine116may be preprogrammed to analyze the target data120for conformity with the predesignated format. Another example of the predefined criteria can include a completeness criteria. The target data120can be deemed to satisfy the completeness criteria if the target data120has a specific, predesignated set of parameters. The target data120can be deemed not to satisfy the completeness criteria if the target data120excludes at least one parameter in the predesignated set of parameters. The validation engine116may be preprogrammed to analyze the target data120to ensure it has all parameters in the predesignated set of parameters.

The validation engine116can determine that the target data120is valid if the target data120satisfies the one or more predefined criteria. In response to determining that the target data120is valid, the validation engine116can return the target data120to the client application114for use in performing the particular computing operation132. In response to determining that the target data120is invalid, the validation engine116can return an error message130to the client application114. This may prevent the client application114from performing the particular computing operation132.

By positioning the selection engine118as an intermediary between the validation engine116and the server104, the selection engine118can help control which part or parts of the server's response112are delivered to the validation engine116. This filtering and control mechanism can reduce the likelihood of the validation engine116determining that the response112is invalid, which in turn can improve operation of the client application114(e.g., because the client application114can execute computing operations it may otherwise be unable to execute if the response112is deemed invalid).

AlthoughFIG.1shows a certain number and arrangement of components, this is intended to be illustrative and non-limiting. Other examples may include more components, fewer components, different components, or a different arrangement of the components shown inFIG.1. For instance, although the engines116,118are shown inFIG.1as separate components, in other examples the selection engine118can include the validation engine116(or vice-versa). Thus, the selection engine118may implement at least some of the functionality of the validation engine116(or vice-versa) in other examples.

FIG.2shows another example in which the validation engine116is separate from the client application114. In this example, the validation engine116can execute the validation process on the target data120. Depending on the results of the validation process, the validation engine116can either forward the target data120to the client application114or transmit an error message130to the client application114.

FIG.3shows another example in which the validation engine116and the selection engine118are both parts of the client application114. In this example, the client application114can receive the response112from the server104and pass the response112to the selection engine118(e.g., rather than the validation engine116). The selection engine118can then identify the target data120in the response112and forward the target data120to the validation engine116. Upon receiving the target data120, the validation engine116can execute the validation process on the target data120. Depending on the results of the validation process, the validation engine116can either return the target data120or return an error message130.

FIG.4shows yet another example of a system400according to some aspects of the present disclosure. The system400includes a processor402communicatively coupled to a memory404. In some examples, the processor402and the memory404may be parts of the same computing device, such as the client device102ofFIG.1. In other examples, the processor402and the memory404may be distributed from (e.g., remote to) one another.

The processor402is hardware that can include one processing device or multiple processing devices. Non-limiting examples of the processor402include a Field-Programmable Gate Array (FPGA), an application-specific integrated circuit (ASIC), or a microprocessor. The processor402can execute instructions406stored in the memory404to perform computing operations. In some examples, the instructions406may correspond to the client application114, the selection engine118, the validation engine116, or any combination thereof. The instructions406may include processor-specific instructions generated by a compiler or an interpreter from code written in any suitable computer-programming language, such as C, C++, C #, Python, or Java.

The memory404can include one memory device or multiple memory devices. The memory404can be volatile or can be non-volatile, such that it can retain stored information when powered off. Some examples of the memory404can include electrically erasable and programmable read-only memory (EEPROM), flash memory, or any other type of non-volatile memory. At least some of the memory404includes a non-transitory computer-readable medium from which the processor402can read instructions. A computer-readable medium can include electronic, optical, magnetic, or other storage devices capable of providing the processor402with computer-readable instructions or other program code. Some examples of a computer-readable medium include magnetic disks, memory chips, ROM, random-access memory (RAM), an ASIC, a configured processor, optical storage, or any other medium from which a computer processor can read the instructions406.

In some examples, the processor402can execute the instructions406to perform some or all of the functionality described herein. For example, the processor402can receive a response112from a server104to an application programming interface (API) request110transmitted by a client application114. The response112can include target data120and other data122. The processor402can determine that the target data120is to be validated. In response to determining that the target data120is to be validated, the processor402can allow a validation process408to be performed on the target data120and prevent the validation process308from being performed on the other data122. The validation process408can involve determining whether the target data120satisfies one or more predefined criteria410.

FIG.5is a flow chart of another example of a process for selective validation of a portion of a server response in accordance with some aspects of the present disclosure. Other examples may involve more steps, fewer steps, different steps, or a different order of the steps than are shown inFIG.5. The steps ofFIG.5will now be described below with reference to the components ofFIGS.1-4described above.

In block502, the processor402receives a response112from a server104to an application programming interface (API) request110transmitted by a client application114. The processor402can receive the response112from the server104via one or more networks106. The API request110can be a single request and the response112can be a single response to the single request. The response112can include a dataset124that contains target data120and other data122.

In block504, the processor402determines that the target data120is to be validated. For example, the processor402can determine that the target data120is to be validated based on settings128, which may be stored in a configuration file126or elsewhere. The settings128may be set by a user prior to, or during, execution of the client application114. For example, the settings128may be updated while the client application114is running, so that the data selected for validation is dynamically changeable without having to shutdown the client application114. This may yield advantages over alternative approaches (e.g., applying an update to the client application114) that may require the client application114to be shutdown, resulting downtime in which the client application114is inoperable.

In some examples, the processor402can additionally or alternatively determine that the other data122is to be ignored. For example, the processor402can determine that the other data122is to be ignored based on the settings128.

In block506, the processor402allows a validation process408to be performed on the target data120and prevents the validation process308from being performed on the other data122. The processor can perform these operations in response to determining that the target data120is to be validated. The validation process408can involve determining whether the target data120satisfies one or more predefined criteria410. Examples of the predefined criteria410can include a formatting criteria and a completeness criteria.

In some aspects, a selected portion of a dataset provided by a server as a response to a request from a client application can be validated according to one or more of the following examples. As used below, any reference to a series of examples is to be understood as a reference to each of those examples disjunctively (e.g., “Examples 1-4” is to be understood as “Examples 1, 2, 3, or 4”).Example #1: A non-transitory computer-readable medium comprising program code that is executable by a processor for causing the processor to: receive a response from a server to an application programming interface (API) request transmitted by a client application, the response including target data and other data; determine that the target data is to be validated; and in response to determining that the target data is to be validated, allow a validation process to be performed on the target data and prevent the validation process from being performed on the other data, wherein the validation process involves determining whether the target data is satisfies one or more predefined criteria.Example #2: The non-transitory computer-readable medium of Example #1, wherein the validation process is configured to determine whether the target data is compatible with the client application.Example #3: The non-transitory computer-readable medium of any of Examples #1-2, wherein the one or more predefined criteria include a formatting criteria, and wherein the validation process is configured to determine whether the target data satisfies the formatting criteria by determining whether the target data conforms to a predesignated format.Example #4: The non-transitory computer-readable medium of any of Examples #1-3, wherein the one or more predefined criteria include a completeness criteria, and wherein the validation process is configured to determine that the target data satisfies the completeness criteria based on the target data including a predesignated set of parameters.Example #5: The non-transitory computer-readable medium of any of Examples #1-4, wherein the program code corresponds to a selection engine that is included in the client application.Example #6: The non-transitory computer-readable medium of any of Examples #1-4, wherein the program code corresponds to a selection engine that is separate from the client application, the selection engine being executable to intercept the response from the server prior to response reaching the client application.Example #7: The non-transitory computer-readable medium of Example #6, wherein the selection engine is further executable by the processor for causing the processor to: execute the validation process to determine whether the target data satisfies the one or more predefined criteria; in response to determining that the target data satisfies the one or more predefined criteria, forward the target data to the client application for use by the client application in executing one or more computing operations; and in response to determining that the target data fails to satisfy the one or more predefined criteria, transmit an error message to the client application.Example #8: The non-transitory computer-readable medium of Example #6, wherein the selection engine is further executable by the processor for causing the processor to: forward the target data to the client application, the client application being configured to perform the validation process on the target data; and prevent the other data from being forwarded to the client application.Example #9: The non-transitory computer-readable medium of any of Examples #1-8, wherein the program code is further executable by the processor for causing the processor to: retrieve one or more settings from a configuration file by accessing the configuration file; determine that the target data is to be validated based on the one or more settings; and determine that the other data is to be ignored based on the one or more settings.Example #10: The non-transitory computer-readable medium of any of Examples #1-9, wherein the client application is configured to transmit the API request to the server, the API request being for retrieving a dataset that includes the target data and the other data from the server, and the response including the dataset.Example #11: A method comprising: receiving, by a processor, a response from a server to an application programming interface (API) request transmitted by a client application, the response including target data and other data; determining, by the processor, that the target data is to be validated; and in response to determining that the target data is to be validated, allowing, by the processor, a validation process to be performed on the target data and preventing the validation process from being performed on the other data, wherein the validation process involves determining whether the target data satisfies one or more predefined criteria.Example #12: The method of Example #11, wherein the validation process is configured to determine whether the target data is compatible with the client application.Example #13: The method of any of Examples #11-12, wherein the one or more predefined criteria include a completeness criteria, and wherein the validation process is configured to determine that the target data fails to satisfy the completeness criteria based on determining that the target data excludes at least one parameter of a predesignated set of parameters.Example #14: The method of any of Examples #11-13, wherein the processor executes a selection engine that is part of the client application to: receive the response; determine that the target data is to be validated; allow the validation process to be performed on the target data; and prevent the validation process from being performed on the other data.Example #15: The method of any of Examples #11-13, wherein the processor executes a selection engine that is separate from the client application to: intercept the response from the server prior to response reaching the client application; determine that the target data is to be validated; allow the validation process to be performed on the target data; and prevent the validation process from being performed on the other data.Example #16: The method of Example #15, further comprising: forwarding, by the selection engine, the target data to the client application, the client application being configured to perform the validation process on the target data; and preventing, by the selection engine, the other data from being forwarded to the client application.Example #17: The method of any of Examples #11-15 and 17, further comprising: executing, by a validation engine, the validation process to determine whether the target data satisfies the one or more predefined criteria; in response to determining that the target data satisfies the one or more predefined criteria, providing, by the validation engine, the target data to the client application for use by the client application in executing one or more computing operations; and in response to determining that the target data fails to satisfy the one or more predefined criteria, providing, by the validation engine, an error message to the client application.Example #18: The method of any of Examples #11-17, further comprising: retrieving, by the processor, one or more settings from a configuration file by accessing the configuration file; determining, by the processor, that the target data is to be validated based on the one or more settings; and determining, by the processor, that the other data is to be ignored based on the one or more settings.Example #19: The method of any of Examples #11-118, wherein the client application is configured to transmit the API request to the server, the API request being for retrieving a dataset that includes the target data and the other data from the server, and the response including the dataset.Example #20: A system comprising: a processor; and a memory including instructions that are executable by the processor for causing the processor to: receive a response from a server to an application programming interface (API) request transmitted by a client application, the response including target data and other data; determine that the target data is to be validated; and in response to determining that the target data is to be validated, allow a validation process to be performed on the target data and prevent the validation process from being performed on the other data, wherein the validation process involves determining whether the target data satisfies one or more predefined criteria.Example #21: A non-transitory computer-readable medium comprising program code for a client application, the client application being executable by a processor for causing the processor to: transmit an application programming interface (API) request to a server for retrieving a dataset from the server; receive the dataset in a response to the API request from the server; determine that target data in the dataset is to be validated and that other data in the dataset is to be ignored; in response to determining that the target data is to be validated, execute a validation process to determine whether the target data satisfies one or more predefined criteria; and in response to determining that the other data is to be ignored, prevent the validation process from being executed on the other data.Example #22: The non-transitory computer-readable medium of Example #21, wherein the client application includes a selection engine that is executable by the processor to: determine that the target data in the dataset is to be validated; and determine that the other data in the dataset is to be ignored.Example #23: The non-transitory computer-readable medium any of Examples #21-22, wherein the client application includes a validation engine that is executable by the processor to: determine, by executing the validation process on the target data, that the target data fails to satisfy the one or more predefined criteria; and in response to determining that the target data fails to satisfy the one or more predefined criteria, return an error message to the client application.Example #24: The non-transitory computer-readable medium any of Examples #21-23, wherein the client application includes a validation engine that is executable by the processor to: determine, by executing the validation process on the target data, that the target data satisfies the one or more predefined criteria; and in response to determining that the target data satisfies the one or more predefined criteria, return the target data to the client application for use in performing one or more computing operations.Example #25: The non-transitory computer-readable medium any of Examples #21-24, wherein the client application is further executable by the processor for causing the processor to: retrieve one or more settings from a configuration file by accessing the configuration file; determine that the target data is to be validated based on the one or more settings; and determine that the other data is to be ignored based on the one or more settings.Example #26: A method comprising: transmitting, by a client application executing on a processor, an application programming interface (API) request to a server for retrieving a dataset from the server; receiving, by the client application, the dataset in a response to the API request from the server; determining, by the client application, that target data in the dataset is to be validated and that other data in the dataset is to be ignored; in response to determining that the target data is to be validated, executing, by the client application, a validation process to determine whether the target data satisfies one or more predefined criteria; and in response to determining that the other data is to be ignored, preventing, by the client application, the validation process from being executed on the other data.Example #27: The method of Example #26, wherein the client application includes a selection engine that is executable by the processor to determine that the target data in the dataset is to be validated and that the other data in the dataset is to be ignored.Example #28: The method of any of Examples #26-27, wherein the client application includes a validation engine, and further comprising: determining, by the validation engine executing the validation process on the target data, that the target data fails to satisfy the one or more predefined criteria; and in response to determining that the target data fails to satisfy the one or more predefined criteria, returning, by the validation engine, an error message to the client application.Example #29: The method of any of Examples #26-27, wherein the client application includes a validation engine, and further comprising: determining, by the validation engine executing the validation process on the target data, that the target data satisfies the one or more predefined criteria; and in response to determining that the target data satisfies the one or more predefined criteria, returning, by the validation engine, the target data to the client application for use in performing one or more computing operations.Example #30: The method of any of Examples #26-29, further comprising: retrieving one or more settings from a configuration file by accessing the configuration file; determining that the target data is to be validated based on the one or more settings; and determining that the other data is to be ignored based on the one or more settings.Example #31: A non-transitory computer-readable medium comprising program code for a selection engine that is separate from a client application, the selection engine being executable by a processor for causing the processor to: intercept a response from a server to an application programming interface (API) request issued by the client application, the API request being for retrieving a dataset from the server, and the response including the dataset; determine that target data in the dataset is to be validated and that other data in the dataset is to be ignored; in response to determining that the target data is to be validated, forward the target data to a validation engine configured to perform a validation process on the target data, the validation process involving determining whether the target data satisfies one or more predefined criteria; and in response to determining that the other data is to be ignored, prevent the other data from being forwarded to the validation engine.Example #32: The non-transitory computer-readable medium of Example #31, wherein the selection engine, the validation engine, and the client application are located on a client device.Example #33: The non-transitory computer-readable medium of any of Examples #31-32, wherein the client application includes the validation engine.Example #34: The non-transitory computer-readable medium of any of Examples #31-33, wherein the validation engine is configured to: determine whether the target data satisfies the one or more predefined criteria by executing the validation process on the target data; in response to determining that the target data fails to satisfy the one or more predefined criteria, return an error message to the client application; and in response to determining that the target data satisfies the one or more predefined criteria, return the target data to the client application.Example #35: The non-transitory computer-readable medium of any of Examples #31-34, wherein the selection engine is further executable by the processor for causing the processor to: retrieve one or more settings from a configuration file by accessing the configuration file; determine that the target data is to be validated based on the one or more settings; and determine that the other data is to be ignored based on the one or more settings.Example #36: A method comprising: intercepting, by a selection engine that is separate from a client application and executing on a processor, a response from a server to an application programming interface (API) request issued by the client application, the API request being for retrieving a dataset from the server, and the response including the dataset; determining, by the selection engine, that target data in the dataset is to be validated and that other data in the dataset is to be ignored; in response to determining that the target data is to be validated, forwarding, by the selection engine, the target data to a validation engine configured to perform a validation process on the target data, the validation process involving determining whether the target data satisfies one or more predefined criteria; and in response to determining that the other data is to be ignored, preventing, by the selection engine, the other data from being forwarded to the validation engine.Example #37: The method of Example #36, wherein the selection engine, the validation engine, and the client application are located on a client device.Example #38: The method of any of Examples #36-37, wherein the client application includes the validation engine.Example #39: The method of any of Examples #36-38, wherein the validation engine is configured to: determine whether the target data satisfies the one or more predefined criteria by executing the validation process on the target data; in response to determining that the target data fails to satisfy the one or more predefined criteria, return an error message to the client application; and in response to determining that the target data satisfies the one or more predefined criteria, return the target data to the client application.Example #40: The method of any of Examples #36-39, further comprising: retrieving, by the selection engine, one or more settings from a configuration file by accessing the configuration file; determining, by the selection engine, that the target data is to be validated based on the one or more settings; and determining, by the selection engine, that the other data is to be ignored based on the one or more settings.Example #41: A system comprising: means for receiving a response from a server to an application programming interface (API) request transmitted by a client application, the response including target data and other data; means for determining that the target data is to be validated and that the other data is to be ignored; and means for, in response to determining that the target data is to be validated and that the other data is to be ignored, allowing a validation process to be performed on the target data and preventing the validation process from being performed on the other data, wherein the validation process involves determining whether the target data satisfies one or more predefined criteria.