Skip to content

Commit

Permalink
Fix products service errors when creating/updating product (aws-sampl…
Browse files Browse the repository at this point in the history
…es#524)

Fixed a typo and a function that was called without passing through a boolean parameter.
Also removed USERS_SERVICE config parameters, which are not used.
  • Loading branch information
gfaires authored Dec 5, 2023
1 parent 4584e2a commit 68fdd41
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ services:
- DDB_ENDPOINT_OVERRIDE
- IMAGE_ROOT_URL
- WEB_ROOT_URL
- USERS_SERVICE_HOST
- USERS_SERVICE_PORT
- FLASK_CONFIG
- COGNITO_USER_POOL_ID
- COGNITO_USER_POOL_CLIENT_ID
Expand Down
2 changes: 0 additions & 2 deletions src/products/src/products_service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class Config:
CACHE_PERSONALISED_PRODUCTS = os.environ.get('CACHE_PERSONALISED_PRODUCTS', "True") == "True"
IMAGE_ROOT_URL = os.environ.get('IMAGE_ROOT_URL')
WEB_ROOT_URL = os.environ.get('WEB_ROOT_URL')
USERS_SERVICE_HOST = os.environ.get('USERS_SERVICE_HOST')
USERS_SERVICE_PORT = os.environ.get('USERS_SERVICE_PORT', 80)
DATA_DIR = os.environ.get('DATA_DIR', '/src/data')
CATEGORY_DATA = os.path.join(DATA_DIR, os.environ.get('CATEGORY_DATA', "categories.yaml"))
PRODUCT_DATA = os.path.join(DATA_DIR, os.environ.get('PRODUCT_DATA', "products.yaml"))
Expand Down
2 changes: 1 addition & 1 deletion src/products/src/products_service/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def validate_product(product):
invalid_keys = set(product.keys()) - ALLOWED_PRODUCT_KEYS
if invalid_keys:
raise ValueError(f'Invalid keys: {invalid_keys}')
category = get_category_by_name(product['category'])
category = get_category_by_name(product['category'], fully_qualify_image_urls=False)
if not category:
raise ValueError(f'Category {product["category"]} not found')
product['price'] = str(product['price'])
Expand Down
2 changes: 1 addition & 1 deletion src/products/src/products_service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_products_by_id(product_ids):

return jsonify(product), 200

@api.route('/products/id/<product_ids>', methods=['PUT'])
@api.route('/products/id/<product_id>', methods=['PUT'])
def update_products_by_id(product_id):
product = request.get_json(force=True)
existing_product = product_service.get_product_by_id(product_id)
Expand Down

0 comments on commit 68fdd41

Please sign in to comment.