admin管理员组

文章数量:1392003

I am using Python Flask in my Zoho Catalyst Advanced I/O function where I initialized Catalyst Python SDK and when I tried testing the function using catalyst serve command I am getting the below error:

{"error": "CatalystAppError("{'code': 'FATAL ERROR', 'message': 'Catalyst headers are empty'}")"}

I am getting the same error even after I deployed my Advanced I/O function to Catalyst Development environment using catalyst deploy command.

I also attached my function code snippet below for reference:

import logging
from flask import Flask, request, make_response, jsonify
import zcatalyst_sdk


app = Flask(__name__)


@app.route("/server/test/", methods=["GET"])  
def initialize():
    catalyst_app = zcatalyst_sdk.initialize(req=request)
    
    response_data = {
        "status": "success",
        "data": {"Catalyst App Initialized"}
    }

    response = make_response(jsonify(response_data), 200)
    return response

if __name__ == "__main__":
    app.run(debug=True, port=3000)  

I am using Python Flask in my Zoho Catalyst Advanced I/O function where I initialized Catalyst Python SDK and when I tried testing the function using catalyst serve command I am getting the below error:

{"error": "CatalystAppError("{'code': 'FATAL ERROR', 'message': 'Catalyst headers are empty'}")"}

I am getting the same error even after I deployed my Advanced I/O function to Catalyst Development environment using catalyst deploy command.

I also attached my function code snippet below for reference:

import logging
from flask import Flask, request, make_response, jsonify
import zcatalyst_sdk


app = Flask(__name__)


@app.route("/server/test/", methods=["GET"])  
def initialize():
    catalyst_app = zcatalyst_sdk.initialize(req=request)
    
    response_data = {
        "status": "success",
        "data": {"Catalyst App Initialized"}
    }

    response = make_response(jsonify(response_data), 200)
    return response

if __name__ == "__main__":
    app.run(debug=True, port=3000)  

Share Improve this question edited Mar 17 at 10:26 globglogabgalab 5883 silver badges19 bronze badges asked Mar 13 at 5:28 Mark JohnsonMark Johnson 253 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

(I think)

This error occurs when you invoke the function directly instead of Catalyst's gateway endpoint.

When you start the server using catalyst serve command, the services in the current project will be started one by one.

We should not use the direct URL of the Flask server. Instead we need to use the URL that is displayed next to AppSail project name.

In the above example, I should use http://localhost:3001 to access the function.

From the above screenshot, I can see you are trying to run a custom flask application in Advanced I/O function which is not possible since catalyst functions are required to run in the defined template. You can find the sample code snippet for Advnaced I/O function here:

import logging
from flask import Request, make_response, jsonify
import zcatalyst_sdk
'''
Execute below command to install SDK in global for enabling code suggestions
-> python3 -m pip install zcatalyst-sdk
'''

def handler(request: Request):
    app = zcatalyst_sdk.initialize()
    logger = logging.getLogger()
    if request.path == "/":
        response = make_response(jsonify({
            'status': 'success',
            'message': 'Hello from main.py'
        }), 200)
        return response
    elif request.path == "/cache":
        default_segment = app.cache().segment()

        insert_resp = default_segment.put('Name', 'DefaultName')
        logger.info('Inserted cache : ' + str(insert_resp))
        get_resp = default_segment.get('Name')

        return jsonify(get_resp), 200
    else:
        response = make_response('Unknown path')
        response.status_code = 400
        return response

If you need to run your custom snippet for your advanced I/O function we would suggest you try checking AppSail

本文标签: pythonGetting 39Catalyst headers are empty39 error from my Catalyst Advanced IO functionStack Overflow