Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

atlassian/firebase-deploy is failing with odd error

Larry Johnson November 11, 2022

Deployments using Atlassian Firebase pipe are failing with this odd error...

Traceback (most recent call last):
  File "/main.py", line 170, in <module>
      pipe.run()
  File "/main.py", line 69, in run
      functions_dir_path = data["functions"]["source"]
TypeError: list indices must be integers or slices, not str

This failed the same way with versions 1.3.0 and 3.0.0 of the pipe "atlassian/firebase-deploy"

IIUC, here's the code block from the Atlassian code...

# check for alternative path to functions directory
try:
with open('firebase.json', 'r') as f:
data = json.load(f)
functions_dir_path = data["functions"]["source"]
except FileNotFoundError:
pass
except KeyError:
pass

It seems to be looking at our firebase.json for nodes source that is under a node functions. This doesn't seem to jive with my understanding of a firebase.json file. I don't think it even has a plural 'functions' node.

Any help is appreciated.

 

 

 

4 answers

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2023

@Larry Johnson @tomcatbuzz @Danilo Lombardi  hi.
We released a new version 3.1.1 of the firebase-deploy pipe, where the bug should be fixed.
Waiting for your feedback.
Regards, Igor

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 3, 2023

By default the pipe will use nodeJS version 16. You could change this with i.e to use nodeJS version 18 for hosting with `NODE_JS_VERSION` variable:

script:
  - pipe: atlassian/firebase-deploy:3.1.1
    variables:
      KEY_FILE: $KEY_FILE
      NODE_JS_VERSION: '18'

Supported values are: 14, 16 (default), 18.

With `firebase deploy --only functions` command `NODE_JS_VERSION` variable has no power (you could omit it); you have the ability to use nodeJS version provided in the engines field of the package.json file in your functions/ directory started from nodeJS version `10`.

tomcatbuzz January 4, 2023

The pipeline is now failing saying Error: Failed to authenticate, have you run firebase login? I have the KEY_FILE: $KEY_FILE set in the settings like the docs said. 

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 4, 2023

@tomcatbuzz  hi.  Create a new question and provide more details with your pipeline config and log output.

Have you created your KEY_FILE variable according to this article?
bitbucket-cloud/docs/use-multiple-ssh-keys-in-your-pipeline 

Linux

base64 -w 0 < your_key_file

 Mac

base64 < your_key_file

 and then pass the result as value to Repository variables KEY_FILE

tomcatbuzz January 5, 2023

I have now generated 2 base64 encoded variables and both times they are failing. This is based on the google credential json. I think Bitbucket has over complicated the Auth method, since before we could simply use a token before <- easy. It should not take hours of trial and error to Simply have a simple deploy on push solution. This has completely ruined the past experience of pipelines. Thanks for your reply. I am moving to another platform for Deploying. 

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2023

@tomcatbuzz  : "since before we could simply use a token before <- easy." this method is still available.

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 27, 2022

@Larry Johnson hi.
Is it possible in monorepo in different function packages.json have different node versions?

I think about fetching node version from the first element of the list of functions. Is this correct?

Or do you think it is better to just provide node version as a pipe variable NODE_VERSION? 

This solutions will not support multiple node version in different function packages.
Still confusing with multiple node version support, i think this will be hard to implement, is this a real case?

Larry Johnson December 27, 2022

It probably is unreasonable to require the pipeline to support multiple node versions.  But I am no expert in any of the technologies used.

Adding a NODE_VERSION pipe variable would work for us.  If it is present the pipe could skip the code trying to find node version.

I've only been looking at main.py in the MAIN branch.  Unless I'm missing something, it seems line 75 always reverses whatever may be done in line 69.  I'm guessing I'm not looking at the latest code.

Also, we use the pipe for firebase 'hosting' sites as well, which has worked well for us.  But as I look at the main.py in the MAIN branch, I do not see how that version ever handled hosting sites.

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 27, 2022

@Larry Johnson 

```It probably is unreasonable to require the pipeline to support multiple node versions.  ``` we already support multiple node versions:

n@6.7.0 && n 8 && n 10 && n 12 && n 14 && n 16


``` line 75 always reverses whatever may be done in line 69.``` -- thats true, this will be fixed.


I will add a little clarification about what i asking. My question was about monorepo:

$  tree .
├── firebase.json
├── teamA
  ├── index.js
  └── package.json
└── teamB
   
├── index.js
   
└── package.json

as you can see here is the list (your case) with two package.json present.

Content of firebase.json:

"functions": [
 
{
   
"source": "teamA",
   
"codebase": "team-a"
 
},
 
{
   
"source": "teamB",
   
"codebase": "team-b"
 
},
]

When you will run this all is ok when node version is the same (node 16 here):

$ firebase deploy --only functions
i  deploying functions
i  functions
: preparing codebase team-a for deployment
i  functions
: preparing codebase team-b for deployment
i  functions
: creating Node.js 16 function team-a:helloATeam(us-central1)...
i  functions
: creating Node.js 16 function team-b:helloBTeam(us-central1)...
...

My question: is it possible to be different node version in package.json teamA and package.json teamB. And if yes, then what firebase cli will do.

Previously we don't have such cases (with monorepo), so i'm a little confused.

Anyway i will thinking about feature to provide node as a pipe variable.

Larry Johnson December 28, 2022

I'm not an expert on Firebase or Node.  But to answer as best I can...

I would think the Firebase CLI would allow multiple node versions.  

But I can see where you can make it a requirement for the pipeline that all versions be the same.  We're a greenfield project so this should not be a problem for us.  Not so sure about other clients.

Sorry if this is no help, but don't want to pretend to be an expert.

Like Igor Stoyanov likes this
Danilo Lombardi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 29, 2022

The same error here. @Larry Johnson could you help me.

Danilo Lombardi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 29, 2022

Where is the place to add a NODE_VERSION? I tried at bitbucket-pipelines.yml

NODE_VERSION: '16'
 but i found the same error. 

Screen Shot 2022-12-29 at 16.42.49.png

Larry Johnson December 29, 2022

@Danilo Lombardi , That feature has not been added. The conversation started by @Igor Stoyanov on December 27 is regarding the various possible changes that Atlassian might be making to the pipe to address this problem.  In another conversatio on this same topic, Igor thinks the fix may be available in a few days or a few weeks.

 

I know that is no help, sorry.  Hope you have a wonderful New Year.

tomcatbuzz December 29, 2022

@Danilo Lombardi if it is for Functions, the node version is defined in the package.json for your functions folder. Using 

"engines": {
    "node": "16"
  },
but that should be auto generated when you install dependencies. As Larry mentioned, we think the pipeline version 3.0.0 is currently bugged since it is failing and won't deploy to hosting. It would be nice if an earlier version could be used, but I have tried other pipeline versions, but when executed it will search for and use Version 3.0.0 pipeline image and fail. 
0 votes
Larry Johnson December 6, 2022

It appears that the Bitbucket Pipeline for firebase-deploy has a bug.  It expects the firebase.json to have an object at the path 'functions/source', where as a monorepo will have an array in this location.

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 13, 2022

Hi @Larry Johnson . Thanks for your feedback. Yes, seems like this i bug according to your investigation. We will dive deep into this this and notify you about results.

 

Regards, Igor

Like Larry Johnson likes this
tomcatbuzz December 19, 2022

I am having the same error and keep changing deploy templates. It is failing every deploy. Well I used to love the simplicity of the deploy pipelines but obviously the new 3.0.0 is not working. And how many weeks does it take to fix this? If it gets fixed I will try again. Going to just script my own deploy for now on push. 

Like Larry Johnson likes this
Larry Johnson December 22, 2022

@Igor Stoyanov ,  Do you know when this will be resolved?

 

@tomcatbuzz Would you be willing to share your solution?  I was thinking I'd have to resort to a Container 

tomcatbuzz December 22, 2022

@[deleted] I just have to run firebase deploy manually from the cli. If the new pipeline image 3.0.0 is failing for its Primary purpose of deploying to firebase it is useless in my opinion. I have older deploys still working with image 1.2.4 and $FIREBASE_TOKEN. The newer updates tell us to use the KEYS as of recent changes. I have not resorted to making an older template to work with TOKEN. I am not even sure it will work. If it is not FIXED soon I will USE Github Actions for Firebase Deploy. I have a project in Github using Github Actions and works like it is supposed to. 

NOTE: A work around (depends on your setup) is creating a script in your package.json. 

Similar to ```build: your build script``` 

I created this to build, commit, and deploy ```

"deploy": "npm run build && git add . && git commit -m 'wip' && git push -u origin master && firebase deploy --only hosting"```
I am having a cli issue though keeping this from completing the deploy portion on my machine. Maybe a node issue, but it opens my firebase.config file instead. 
Like Larry Johnson likes this
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 22, 2022

@Larry Johnson hi. We will try to release a new version from few days to 3 weeks. 

Regards, Igor

Larry Johnson December 23, 2022

@tomcatbuzz thanks for the detail.

 

@Igor Stoyanov Thanks for your attention to this. We're trying to stick with Atlassian Pipelines and look forward to the new release.  In the meantime, do you know of a Container Image we can use that has the Firestore CLI installed?  If not, I guess we can create one.

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 24, 2022

In the meantime, do you know of a Container Image we can use that has the Firestore CLI installed

I don't know any official docker images for Firestore CLI.

tomcatbuzz December 24, 2022

@Larry Johnson I did a search and found this repo. I don't really use docker, but this seems to be a repo that is being maintained and also listed on docker.hub. https://github.com/AndreySenov/firebase-tools-docker

0 votes
Larry Johnson November 14, 2022

Looking at main.py in the atlassian/firebase-deploy, what good is this code at L:63

 

# check for alternative path to functions directory
try:
    with open('firebase.json', 'r') as f:
        data = json.load(f)
        functions_dir_path = data["functions"]["source"]
except FileNotFoundError:
    pass
except KeyError:
    pass

When it's immediately followed by this line that overwrites it at L:75
functions_dir_path = DEFAULT_FUNCTIONS_DIR_PATH

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events